Question

Issues with SFTP access after using sudo find command

Posted March 5, 2021 217 views
Linux CommandsUbuntu 20.04

Hello,

I ran the following commands yesterday to update the permissions on files and directories for my WordPress site and now I cannot connect to the parent directory (name.com - example directory name) using SSH or SFTP.

sudo find /var/www/name.com/ -type f -exec chmod 640 {} \;
sudo find /var/www/name.com/ -type d -exec chmod 750 {} \;

These commands were recommended on this tutorial article: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04.

My FTP client (Transmit, macOS) displays this error when trying to connect: Could not change directory to “/var/www/callkneehill.ca/wp-content/themes”.

Could someone share what is going wrong and possibly let me know how best to set permissions so that SSH and SFTP work correctly.

Cheers,

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hello, @mikehermary

Could you please clarify if the only directory you can’t access is the wp-content/themes? Can you access the WordPress core installation directory - public_html

I will recommend you manually check the current permissions and ownership of the directory and verify they’re indeed 750 for directories and 640 for the files.

Running these command should not cause any harm as they’re the recommended permissions for a WordPress site.

Regards,
Alex

Hello Alex,

Thanks for the reply.

When I connect to the server via SSH using sudo and use the following command cd /var/www/callkneehill.ca, Terminal displays the following message: -bash: cd: /var/www/callkneehill.ca: Permission denied.

I tried checking the permissions using ls -l /var/www/callkneehill.ca and the following message was displayed: ls: cannot open directory ’/var/www/callkneehill.ca’: Permission denied.

If I run the sudo chown -R www-data:www-data /var/www/callkneehill.ca command, I can access the directory, but the website itself goes down.

Any ideas on why I am having issues?

Cheers,