ssh-copy-id 和 ssh- agent

看了半天也不知道这是什么鬼技巧, 大概就是说了一个问题, 然后怎样解决这个问题.

翻译模式开启:

如果没有-i的参数或者~/.ssh/identity.pub不可用, ssh-copy-id就会报错:

  1. jsmith@local-host$ ssh-copy-id -i remote-host
  2. /usr/bin/ssh-copy-id: ERROR: No identities found

如果你用ssh-add加载了公钥到ssh-agent的话, ssh-copy-id就会ssh-agent那里得到公钥并且拷贝到远程服务器.

  1. jsmith@local-host$ ssh-agent $SHELL
  2. jsmith@local-host$ ssh-add -L
  3. The agent has no identities.
  4. jsmith@local-host$ ssh-add
  5. Identity added: /home/jsmith/.ssh/id_rsa
  6. (/home/jsmith/.ssh/id_rsa)
  7. jsmith@local-host$ ssh-add -L
  8. ssh-rsa
  9. AAAAB3NzaC1yc2EAAAABIwAAAQEAsJIEILxftj8aSxMa3d8t6JvM79D
  10. aHrtPhTYpq7kIEMUNzApnyxsHpH1tQ/Ow==
  11. /home/jsmith/.ssh/id_rsa
  12. jsmith@local-host$ ssh-copy-id -i remote-host
  13. jsmith@remote-hosts password:
  14. Now try logging into the machine,
  15. ... ... ...

首先我们看到, ssh-add -L没有回显任何已有的公钥, 添加以后, 再用ssh-copy-id就可以以默认的公钥拷贝到远程主机上了.

也许作者在这里是想说明这几个软件之间的关系, 尽管有别的方法拷贝, 或者补全参数就能搞定.

(但我相信作者是在这里充数啊!!! -.-)