3

Website Information:

Protocol : SFTP

Server : Google Cloud

Wordpress Version : 4.9.8

I am trying to update my WordPress plugins but every time I try to do it, it always asks me for my FTP information but when I supplied my FTP information it returns an error 'Failed to connect to FTP Server.'

I even tried to add Port number '21' and '22' on the hostname but it still doesn't work. I even tried using 'FTPS (SSL)' Connection type but it didn't work either. I've also used the plugin 'SSH SFTP Updater Support' but it leaves my website under maintenance and I can't access it anymore.

I've spent 2 days resolving this problem. Hope that someone can help me with this.

Thank you in advance :)

Oliver Primo
  • 317
  • 4
  • 18

2 Answers2

8

If only FTP and FTPS (SSL) appear as options on WordPress when installing plugins, etc., then installing the PHP extension for SSH2 will automatically add an SSH2 option (for SFTP) to WordPress.

For example, on Ubuntu:

sudo apt install php-ssh2

And restart the web server (e.g. Nginx or Apache).

jmg
  • 181
  • 2
  • 4
3

FTP and SFTP are two different protocols. Wordpress offers a facility to upload plugin via FTP. However Wordpress does not have SFTP support to install plugins as of now, AFAIK. You can go with any of the following routes.

  • Enable Direct Method Wordpress will be able to install plugins automatically and FTP or SFTP will not be needed. You need to edit wp-config and add following line:

     define('FS_METHOD', 'direct');
    

    You can read more on this post

  • Upload plugin zip file via SFTP You can download plugin and then upload downloaded zip file via your SFTP client e.g FileZilla or you can do it from terminal (on Unix Systems) using scp. Reference for installing plugin manually can be found here and instructions on using scp on Linux can be found here

creyD
  • 1,972
  • 3
  • 26
  • 55
Kamran Syed
  • 439
  • 3
  • 7
  • Thank you for this. I will try your suggestions and hope that this will solve my problem :) – Oliver Primo Nov 09 '18 at 06:10
  • You @OliverPrimo are welcome. Please comment if problem persists. – Kamran Syed Nov 09 '18 at 07:01
  • Hello @KamranSyed. I tried to add 'define('FS_METHOD', 'direct');' to my wp-config.php and it doesn't require me to supply my FTP info anymore but the problem is that it returns an error 'Update Failed: Could not create directory.' every time I update a plugin. Regarding the second solution, it is possible to upload a plugin through SFTP but my problem is updating the plugins. Anyways, Thank you for your response :) – Oliver Primo Nov 09 '18 at 07:35
  • It has to do with the permissions. Webserver is not able to write on `/wp-content/plugins/`. Please see this post for permissions. https://stackoverflow.com/questions/640409/can-i-install-update-wordpress-plugins-without-providing-ftp-access. I would need to know OS and Webserver installed to provide specific commands. Thanks. – Kamran Syed Nov 09 '18 at 07:55
  • Okay. Many thanks to you for getting back to me. I'll inform later regarding the information you're asking for. Thank you :) May I ask, wouldn't it cause vulnerability to the site once I allowed write permission to my wp-content? – Oliver Primo Nov 09 '18 at 08:18
  • Hello @KamranSyed, I already updated the file permissions of wp-content and wp-content/plugins/ to 777 but it still returns an error: 'Update Failed: Could not create directory.' every time I update a plugin. I'm sorry for being slow but I am a newbie with this. Thank you for your assistance :) – Oliver Primo Nov 09 '18 at 08:33
  • This vulnerability is inherent in all solutions, allowing webserver to upload files, including Wordpress. `/wp-content/uploads/` is always writable by wordpress (webserver). – Kamran Syed Nov 09 '18 at 08:33
  • Hello @KamranSyed, I already updated the file permissions of wp-content and wp-content/plugins/ to 777 but it still returns an error: 'Update Failed: Could not create directory.' every time I update a plugin. I'm sorry for being slow but I am a newbie with this. Thank you for your assistance :) – Oliver Primo Nov 09 '18 at 08:36
  • Permissions 777 will not work as discussed in the stackover post, I mentioned earlier. Please follow the instructions in the post or from Internet to set Wordpress permissions. @OliverPrimo – Kamran Syed Nov 09 '18 at 08:36
  • Thank you for your response @KamranSyed. I really appreciated your time and effort. I already fixed this with your second solution by downloading the latest plugin and uploading it to the server via Filezilla. Thank you again :) – Oliver Primo Nov 12 '18 at 05:18