假设我有一个 Github 的密钥以及其他密钥。我ssh-add -L在我的家用电脑 A 上为我的 ssh 代理添加了很多密钥(返回很多行)。在我的.ssh/config我已经设置了哪个密钥用于哪个主机,例如
ssh -T -vvv git@github.com 2>&1 | grep Offering
Run Code Online (Sandbox Code Playgroud)
给
debug1: Offering RSA public key: /Users/doxna/.ssh/id_rsa.github
Run Code Online (Sandbox Code Playgroud)
正如预期的那样,只提供了一把钥匙。但是然后使用 ssh-ing 连接到某个主机 BForwardAgent yes并重复相同的命令,我得到
debug1: Offering RSA public key: /Users/doxna/.ssh/id_rsa.linode2
debug1: Offering RSA public key: /Users/doxna/.ssh/id_rsa.helium
debug1: Offering RSA public key: /Users/doxna/.ssh/id_rsa.github
Run Code Online (Sandbox Code Playgroud)
这意味着它会尝试我所有的钥匙。这是有问题的,因为在服务器返回之前只能尝试有限数量的密钥Too many authentication failures。所以我尝试.ssh/config在主机 B 上编辑以包括
Host github.com
IdentityFile /Users/doxna/.ssh/id_rsa.github
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
但后来我没有得到关键的产品,而是
debug2: key: /Users/doxna/.ssh/id_rsa.github ((nil))
Run Code Online (Sandbox Code Playgroud)
我猜这意味着找不到密钥(?)毕竟,密钥位于我的家用计算机 A 上,而不是主机 B,所以问题是如何在主机 B 上引用它?希望我设法解释了这个问题。
kas*_*erd 33
你的想法是对的。您唯一缺少的部分是指向的文件IdentityFile必须存在。它不需要包含私钥,只要有可用的公钥就足够了。
在主机 B 上,您可以通过键入从代理中提取公钥ssh-add -L | grep /Users/doxna/.ssh/id_rsa.github > ~/.ssh/id_rsa.github.pub,然后从以下位置指向该文件~/.ssh/config
@Kasperd 的回答很好,但还要注意,如果主机 B 受到威胁,或者如果您不信任那里的所有具有 root 权限的人,那么只要您登录,您的所有密钥仍然会被滥用在那个主机上。
因此,更好的方法可能是仅转发对您需要的密钥的访问。也许尝试ssh-agent-filter在 debian / Ubuntu 存储库中或来自github 中的哪个。
编辑:我已经决定ssh-ident而不是ssh-agent-filter有选择地转发密钥,尽管它并不像人们希望的那样顺利。
| 归档时间: |
|
| 查看次数: |
12246 次 |
| 最近记录: |