I'm trying to connect with rsync to a GCP vm. Whenever I do, I'm getting weird errors related to permissions.
I've checked that my username is part of the sudoers group so I can't really see where the issue is coming from. I logged in to my GCP instance which created a user dir under /home following my Mac OS username format,
Here are the commands I've been trying, and the results…
C02YT3UDLVDL:proj-name j.lname$ ssh -i ~/.ssh/google_compute_engine
j.lname@xx.xxx.xxx.xx The authenticity of host 'xx.xxx.xxx.xx (xx.xxx.xxx.xx)'
can't be established. ECDSA key fingerprint is
SHA256:JW7VfidHTsAtq8JjF9bEkdfIjdskIAadfs80.Are you sure you want to continue
connecting (yes/no)? yes Warning: Permanently added 'xx.xxx.xxx.xx' (ECDSA) to
the list of known hosts.
After which I try moving a test dir…
rsync -Pavz testDir/* xx.xxx.xxx.xx:/home/j.lname
And get
ssh_exchange_identification: Connection closed by remote host
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
Trying it one more time get:
$ rsync -Pavz testDir/* xx.xxx.xxx.xx:/home/j.lname/
The authenticity of host 'xx.xxx.xxx.xx (xx.xxx.xxx.xx)' can't be established.
ECDSA key fingerprint is SHA256:Q8kqWi3iyLno3Q8kqWi3iyLno3Q8kqWi3iyLno3.
ECDSA key fingerprint is MD5:ff:56:c3:21:cc:f1:a7:62:1b:72:bc:54:8e:f7:c8:1a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'xx.xx.xx.xx' (ECDSA) to the list of known hosts.
yPermission denied (publickey).
Edited:
At the advice of someone on here also tried
rsync -Pavz -e "ssh -i ~/.ssh/google_compute_engine" testDir/*
j.lname@xx.xxx.xxx.xx:/home/j.lname/
And that time got:
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far)
[sender]
rsync error: error in rsync protocol data stream (code 12) at
io.c(226) [sender=3.1.3]
Best Answer
With rsync you have to specify the ssh key as you do with ssh. That's why you get a permission denied. We can do it with the -e option :
Edit:
Rsync command should be installed on the destination server too