Both my server and pc are running Ubuntu 20.04. For accessing my server (ksm-server1) with SSH I use SSH keys. Login into my server over SSH works as expected. But when I copy files from my client pc to my server, it seems it’s not using my SSH keys. Let me explain below.
On my pc I setup my .ssh/config file like this:
Host ksm-server1
Hostname 192.168.2.7
IdentityFile ~/.ssh/ksm-server1_key
Port 22
User kees
To login on my server from my pc I use:
ssh ksm-server1
This works as expected: the server let’s me login by using my passphrase.
But when I use rsync like this on my pc:
sudo rsync -a /home/kees/test ksm-server1:/home/kees/documenten/test_rsync
it first asks me for the password for root on the server. What I would expect is that it uses my SSH-key to login to the server and not asking me for a password on the first place, but certainly not the password for root. This is something I don’t understand. Could someone explain this to me?
When I use rsync like this:
sudo rsync -a /home/kees/test kees@ksm-server1:/home/kees/documenten/test_rsync
the server asks me for the password of user kees on the server. If I enter this password, rsync works as expected.
Any help is appreciated!