I have ssh RSA key authentication setup between a client and an ubuntu server (following this procedure):
-the RSA key authentication for ssh
and rsync
work fine (no need for password).
-the RSA key authentication for sudo rsync
and sudo ssh
fails (I'm prompted for a password).
-I need to use sudo rsync
to write the remote files locally.
I'm running the command as follows:
user1@server:/$ sudo su user2
user2@server:/$ rsync 192.168.1.2:... # ok
user2@server:/$ sudo rsync 192.168.1.2:... # remote host password prompt
FYI both user1 and user2 are part of sudoers
Any idea where that could be coming from?
Thanks.
updated: to clarify, the password prompt is not coming from sudo but from the server
su - user
The - will cause you to inherit the users environment. Alternatively you could specify the path to the key file : something like rsync -e ssh -i /home/user2/.ssh/private.key