我有一个客户端和Ubuntu服务器之间的RSA密钥authentication设置( 按照此过程 ):
-ssh和rsync的RSA密钥authentication工作正常(不需要密码)。
– sudo rsync和sudo ssh的RSA密钥authentication失败(提示input密码)。
– 我需要使用sudo rsync来在本地写入远程文件。
我正在运行命令如下:
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 user1和user2都是sudoers的一部分
任何想法可能来自哪里?
谢谢。
更新:澄清,密码提示不是来自sudo,而是来自服务器
你需要告诉它使用正确的公钥。 我怀疑ssh仍在使用user1的键,而不是user2。 使用这个命令:
sudo -u user2 ssh -i ~user2/.ssh/id_rsa remoteserver
我在我的机器上testing了它,它工作。
这个问题在
#/etc/sudoers ====at the end of file add this==== user1 ALL = NOPASSWD:ALL
这将使用sudo命令删除user1的密码promt。
不要忘记,sudo用户可能会将他们的ssh密钥存储在/root/.ssh/中,而不是在/home/user1/.ssh/中