When I try to upload files to my server I am getting a permission denied error. I am able to see all the files through filezilla and even download them but when I try to upload it doesn't let me. I also can't create directories. I have checked the file permissions and made sure port 22 is open. What would be causing me to not be able to upload the files?

I have this setup on Google Compute Engine and implemented a LAMP system. I have also tried to put files and create directories through the ssh terminal but get the same permission denied error. However, I am able to edit files with the sudo nano command.

I found I can only upload to a home folder that is listed, home/username. How do I add permissions for other folders like var/www?


If the only editing you've been able to do is a) through sudo, and b) in the home folder, you are using a non-root user. That's a good thing, but it means you'll run into exactly these constraints. If you want to upload directly to /var/www without being root, you could adjust the ownership or permissions on that folder, like this:

sudo chown $USER /var/www

Or, you can just upload files into the home folder, and then copy them into place through the interactive session:

sudo cp -p ~/newfile.html /var/www/

The key is that you'll need to use sudo to make changes that aren't allowed otherwise.

| improve this answer | |
  • thank you so much! I am new to this and was searching for this answer for hours yesterday! – Michael St Clair Oct 8 '14 at 14:08
  • Wow 8 hours in and I finally stumble on your answer. Thank you so much – Tony Brix Apr 5 '15 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.