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


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.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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.