禁用基于密码的登录后,是否可以使用ssh-copy-id?


Answers:


6

如果您有多个ssh密钥,并且已经在服务器上设置了一个用于身份验证的密钥,或者如果您有其他一些非密码身份验证系统,那么我相信您可以ssh-copy-id用来将ssh身份复制到服务器。在ssh-copy-id手册页中说:

ssh-copy-id是一个使用ssh登录到远程计算机的脚本(大概使用登录密码,因此应该启用密码身份验证,除非您已经巧妙地使用了多个身份)

ssh-copy-id用于ssh登录到远程计算机,因此,如果当前可以登录到该计算机,则可以使用ssh-copy-id。如果您无法登录机器,则无法使用ssh-copy-id。新的ID将附加到~/.ssh/authorized_keys


3

只是尝试了一下,它看起来不可能。

确认我们具有无密码的SSH访问权限:

ssh root@redmine -- 'whoami'
#    root

我要安装的辅助公钥

ls amir*
#    amir.pub

尝试1:

ssh-copy-id -i amir.pub root@redmine
#    ERROR: failed to open ID file './amir': No such file or directory

据报道这是OpenSSH bug#2110

解决方法:创建伪造的私钥

touch amir

ssh-copy-id -i amir.pub root@redmine
#    INFO: attempting to log in with the new key(s), to filter out any that are already installed
#    INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
#    root@redmine's password:

在这种情况下,除非我遗漏了一些东西,否则它似乎拒绝使用现有密钥。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.