Non-root user can't upload files in filezilla (SFTP)

May 9, 2015 5.3k views
Deployment LAMP Stack Getting Started Ubuntu


I'm following several tutorials on setting up a lamp server en such. I now have a working lamp server with firewall enabled. I read that it is good practice to disable the root account and create a second user with sudo access.

Everything went well, I can connect with PuttY but when I wanted to connect with filezilla I can't upload or modify files. With the root account everything works, but with the second account it does not.

I used following tutorial:

I'm not sure if I'm missing someting here. I'm using the same ssh key for root as for the second account.

3 Answers

Thanks for the anwser, now I've been looking around and used this to achieve my goal. Is this a correct solution?

  1. Establish a [new directory] at /var/www
  2. Change the directory owner and group:
  3. sudo chown www-data:www-data /var/www/[new directory]
  4. allow the group to write to the directory with appropriate permissions:
  5. sudo chmod -R 775 /var/www
  6. Add myself to the www-data group:
  7. sudo usermod -a -G www-data [my username]

Instead of:

sudo chmod -R 775 /var/www/

You could use these two commands to set appropriate file and folder permissions:

sudo find /var/www/[new directory]/ -type f -exec chmod 664 {} \;
sudo find /var/www/[new directory]/ -type d -exec chmod 775 {} \;

And then try on with more restrictive permissions until you're satisfied.

Give the directories you want them to write in the right permissions using chown/chmod.

Have another answer? Share your knowledge.