'How to overcome the error "Unable to connect to the filesystem" in Wordpress using Ubunto 16.04 and trying to utilise FTPS SSL [closed]
I am running:
Ubuntu 16.04.3 LTS
NGINX 1.10.3
ufw
PHP 7.0.22
Wordpress 4.9
After following the steps I outline below I am receiving the following error when I try to install a theme via FTPS (SSL), or plugin from the Wordpress Admin dashboard:
Unable to connect to the filesystem. Please confirm your credentials.
The steps I have taken to enable FTPS SSL access for Wordpress on the server were taken from this Digital Ocean article: https://www.digitalocean.com/community/tutorials/how-to-configure-secure-updates-and-installations-in-wordpress-on-ubuntu
The article was written for Ubunto 14.04, but barring one problem with packages (outlined below), I was able to follow it without any problem.
Steps Followed So Far
Create user account for Wordpress:
sudo adduser wp-user
Give the Wordpress user permission over all files from root www:
cd /var/www/html
sudo chown -R wp-user:wp-user /var/www/html
Create SSH keys for wp-user:
sudo su - wp-user
ssh-keygen -t rsa -b 4096
Told ssh-keygen to store the keys here: /home/wp-user/wp_rsa
Gave Wordpress user ownership of keys, and set www-data as group owner:
sudo chown wp-user:www-data /home/wp-user/wp_rsa*
sudo chmod 0640 /home/wp-user/wp_rsa*
Created SSH folder, set permisions, moved key into there:
sudo mkdir /home/wp-user/.ssh
sudo chown wp-user:wp-user /home/wp-user/.ssh/
sudo chmod 0700 /home/wp-user/.ssh/
sudo cp /home/wp-user/wp_rsa.pub /home/wp-user/.ssh/authorized_keys
Set permissions on authorized keys folder:
sudo chown wp-user:wp-user /home/wp-user/.ssh/authorized_keys
sudo chmod 0644 /home/wp-user/.ssh/authorized_keys
Restricted login to the server:
sudo nano /home/wp-user/.ssh/authorized_keys
[then added] from="127.0.0.1 " [to the start of the file]
Part of the guide I wasn't able to follow:
The next steps are:
sudo apt-get install php5-dev libssh2-1-dev libssh2-php
I'm using php7, so instead I used:
sudo apt-get install php7.0-dev libssh2-1-dev libssh2-1
These executed successfully.
Finally the guide says to edit the wp-config file adding these defines at the end:
define('FTP_PUBKEY','/home/wp-user/wp_rsa.pub');
define('FTP_PRIKEY','/home/wp-user/wp_rsa');
define('FTP_USER','wp-user');
define('FTP_PASS','');
define('FTP_HOST','127.0.0.1:22');
Which I did. I restarted NGINX. Site loaded fine, but the above error was reported when I tried to upload a theme, using FTPS (SSL).
Troubleshooting
- I've have checked the
/home/wp-user/.ssh/authorized_keysand the SSH key is in that file. I have checked that port 22 is open. Netstat reports:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
How can I overcome this error? What might I try next to try to further troubleshoot?
Solution 1:[1]
Just add this line at the end of wp-config.php file
define("FS_METHOD", "direct");
Reload the webpage and try the installation again.
Solution 2:[2]
This was the best answer I got initially but it did not help to solve it completely. I complemented it with someone's answer from the following forum: Wordpress asking for FTP Credentials | DigitalOcean
Running the following commands fix it:
sudo chown username:www-data /var/www -R
sudo chmod g+w /var/www -R
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Suraj Rao |
| Solution 2 |

