Celeb Glow
news | March 18, 2026

Uploading files via sftp failed. Permission denied

I'm trying to upload files to Ubuntu server using sftp. I use put -r dir to upload a folder with all its content. When I run the command it gives something like the following:

 Uploading AuthApp/ to /var/www/html/AuthApp remote open("/var/www/html/AuthApp/.DS_Store"): Permission denied Uploading of file AuthApp/.DS_Store to /var/www/html/AuthApp/.DS_Store failed! remote open("/var/www/html/AuthApp/.gitattributes"): Permission denied Uploading of file AuthApp/.gitattributes to /var/www/html/AuthApp/.gitattributes failed! remote open("/var/www/html/AuthApp/.gitignore"): Permission denied Uploading of file AuthApp/.gitignore to /var/www/html/AuthApp/.gitignore failed! remote open("/var/www/html/AuthApp/artisan"): Permission denied Uploading of file AuthApp/artisan to /var/www/html/AuthApp/artisan failed! remote open("/var/www/html/AuthApp/composer.json"): Permission denied Uploading of file AuthApp/composer.json to /var/www/html/AuthApp/composer.json failed! remote open("/var/www/html/AuthApp/composer.lock"): Permission denied Uploading of file AuthApp/composer.lock to /var/www/html/AuthApp/composer.lock failed! remote open("/var/www/html/AuthApp/CONTRIBUTING.md"): Permission denied Uploading of file AuthApp/CONTRIBUTING.md to /var/www/html/AuthApp/CONTRIBUTING.md failed! remote open("/var/www/html/AuthApp/phpunit.xml"): Permission denied Uploading of file AuthApp/phpunit.xml to /var/www/html/AuthApp/phpunit.xml failed! remote open("/var/www/html/AuthApp/readme.md"): Permission denied Uploading of file AuthApp/readme.md to /var/www/html/AuthApp/readme.md failed! remote open("/var/www/html/AuthApp/server.php"): Permission denied Uploading of file AuthApp/server.php to /var/www/html/AuthApp/server.php failed! Couldn't setstat on "/var/www/html/AuthApp": Permission denied

I tried to change permissions, add user and apache to the group but nothing works. What else am I missing?

2 Answers

The better method would be for your program to upload to a user owned directory on the server (aka /home/$USER/upload/ and install a cron job in /etc/crontab on the server that copies the files over as the user apache is set to (likely www-data or apache2) into /var/www/html/ -after- making a timestamped backup of the files it is going to overwrite.

  • it would solve your problem
  • it would prevent data loss in case your copy does something nasty.
  • no need to mess with the website settings and /var/www/html/

A directory watcher (see how to put a trigger on a directory ) can do this real-time.

2

The tag sudo runs everything as root, which you need to do to run this so instead of sftp -r dir do sudo sftp -r dir then enter your password. Note that you will need root access to do this If this works, please check it and vote it up, so other people can find this if they need it.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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