2
votes

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 :)

2

2 Answers

2
votes

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

2
votes

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).