Ubuntu – Using pscp and getting permission denied

permissionsputtysudoUbuntu

I'm using pscp to transfer files to a virtual ubuntu server using this command:

pscp test.php user@server:/var/www/test.php

and I get the error permission denied. If I try to transfer to the folder /home/user/ I have no problems.

I guess this has to do with that the user I'm using doesn't have access to the folder /var/www/. When I use SSH I have to use sudo to get access to the /var/www/ path – and I do.

Is it possible to specify that pscp should "sudo" transfers to the server so I can get access to the /var/www/ path and actually be able to transfer files to this folder?

Best Answer

If you own the server:

Add yourself to the www-data group:

sudo usermod -a -G www-data <username>

And set the right permissions:

sudo chown -R www-data:www-data /var/www/
sudo chmod -R 0775 /var/www/

This should do the trick.