在一个客户端上使用多个SSH私钥的最佳方法 [英] Best way to use multiple SSH private keys on one client

查看:95
本文介绍了在一个客户端上使用多个SSH私钥的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用多个私钥连接到不同的服务器或同一服务器的不同部分(我的用途是服务器的系统管理,Git的管理以及同一服务器内的正常Git使用).我试图简单地将键堆叠在id_rsa文件中而无济于事.

I want to use multiple private keys to connect to different servers or different portions of the same server (my uses are system administration of server, administration of Git, and normal Git usage within the same server). I tried simply stacking the keys in the id_rsa files to no avail.

显然,一种简单的方法是使用命令

Apparently a straightforward way to do this is to use the command

ssh -i <key location> login@server.example.com 

这很麻烦.

关于如何轻松执行此操作的任何建议吗?

Any suggestions as to how to go about doing this a bit easier?

推荐答案

来自我的.ssh/config:

Host myshortname realname.example.com
    HostName realname.example.com
    IdentityFile ~/.ssh/realname_rsa # private key for realname
    User remoteusername

Host myother realname2.example.org
    HostName realname2.example.org
    IdentityFile ~/.ssh/realname2_rsa  # different private key for realname2
    User remoteusername

以此类推.

这篇关于在一个客户端上使用多个SSH私钥的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆