多个服务器组之间如何配置不同的SSH key

跳板机只有一个 两个服务器群组 一个组用key1 跳板机无密码登录一直没问题 加入组2服务器后使用另外一个key2 现在必须使用ssh -i keyfile user@ip登录

update 2019年4月11日
一个“取巧”的方法 来自stackoverflow
~/.ssh/config开头添加N行IdentityFile ~/.ssh/{key_filename}比如

IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_rsa_old
IdentityFile ~/.ssh/id_ed25519

ssh 将如下

debug1: Trying private key: /home/example/.ssh/id_rsa
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/example/.ssh/id_rsa_old
阅读 2.6k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进