I am trying to transfer files to my Google cloud hosted Linux (Debian) instance via secure copy (scp). I did exactly what the documentation told to connect from a local machine to the instance. https://cloud.google.com/compute/docs/instances/connecting-to-instance.
I can login successfully by:
ssh -i ~/.ssh/my-keygen [USERNAME]@[IP]
But when I want to copy files to the instance I get a message "permission denied".
scp -r -i ~/.ssh/my-keygen /path/to/directory/ [USERNAME]@[IP]:/var/www/html/
It looks like the user with which I login has no permissions to write files, so I already tried to change the file permissions of /var/www/, but this still gives the permission denied message.
I also tried to add the user to the root group, but this still gives the same problem.
usermod -G root myuser
The command line should be
scp -r -i ~/.ssh/my-keygen /path/to/directory/ [USERNAME]@[IP]:/var/www/html/
Assuming your files are in the local /path/to/directory/
and the /var/www/html/
is on the remote server.
The permissions does not allow to write in the /var/www/html/
. Writing to /tmp/
should work. Then you can copy the files with sudo
to the desired destination with root
privileges.