我试图使用非标准密钥名称复制到远程服务器,但它告诉我该密钥已被复制:
$ ssh-copy-id -i /Users/wwerner/.ssh/my_other_key me@example
/usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/local/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on the remote system.
但我知道这是一个谎言,因为当我这样做时:
ssh me@example "cat ~/.ssh/authorized_keys2"
显示我的id_rsa.pub
但不是my_other_key.pub
。
我究竟做错了什么?
答案1
这红帽问题掌握了我的问题的关键*:
我遇到了同样的问题 - 似乎与用户 ssh 配置有关 - 我重命名了我的,重新做了,它起作用了
噢,我想 - 我确实有一个 ssh 配置,而且这不是我复制的第一个密钥,和我example
在文件中指定,而不必键入subdomain.example.com
.
所以我尝试指定满的领域:
ssh-copy-id -i /Users/wwerner/.ssh/my_other_key [email protected] $? 1 12:34:54
/usr/local/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/local/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
繁荣,它奏效了。出色的。
*哈哈哈
答案2
LogLevel quiet
我遇到了同样的问题,发现如果您的 ssh 配置中有 ssh-copy-id 脚本,则该脚本不起作用:它会解析 ssh 输出以Permission denied
获取输出,但无法获取它。