ssh-agent:如何保留登录密钥并添加更多身份?

ssh-agent:如何保留登录密钥并添加更多身份?

当我从 Windows 登录本地 Ubuntu 14 实例时(我使用安全CRT作为 SSH 客户端)使用我的 RSA 密钥,该密钥可用于转发进一步的 SSH 会话(用 列出ssh-add -l)。但是,我无法向默认代理添加更多身份:

# ssh-add -l
2047 29:c7:24:ca:ee:21:c8:1c:8e:31:7b:60:d9:45:45:df "rsa-vwal-20160112" (RSA)
# ps aux | grep ssh-agent
ville      3102  0.0  0.1  12968  2280 pts/3    S+   02:13   0:00 grep --color=auto ssh-agent
# env | grep SSH
SSH_CLIENT=192.168.50.101 30920 22
SSH_CONNECTION=192.168.50.101 30920 192.168.220.20 22
SSH_TTY=/dev/pts/3
SSH_AUTH_SOCK=/tmp/ssh-UVKqhSow2l/agent.2679
# ssh-add /home/ville/.ssh/keys/gitkey/gitkey
Enter passphrase for /home/ville/.ssh/keys/gitkey/gitkey: 
SSH_AGENT_FAILURE
Could not add identity: /home/ville/.ssh/keys/gitkey/gitkey
#

我认为这是因为没有真正的ssh-agent过程;显然初始代理是由sshd(?)提供的

现在,如果我启动一个新代理并应用它生成的环境变量以便进行更改SSH_AUTH_SOCK,我可以向代理添加身份...

# ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-G8dg8bePFC8K/agent.3115; export SSH_AUTH_SOCK;
SSH_AGENT_PID=3116; export SSH_AGENT_PID;
echo Agent pid 3116;
# SSH_AUTH_SOCK=/tmp/ssh-G8dg8bePFC8K/agent.3115; export SSH_AUTH_SOCK;
# SSH_AGENT_PID=3116; export SSH_AGENT_PID;
# ps aux | grep ssh-agent                  
ville      3116  0.0  0.0  10628   320 ?        Ss   02:16   0:00 ssh-agent
ville      3128  0.0  0.1  12968  2120 pts/3    S+   02:20   0:00 grep --color=auto ssh-agent
# ssh-add -l
The agent has no identities.
# ssh-add /home/ville/.ssh/keys/gitkey/gitkey
Enter passphrase for /home/ville/.ssh/keys/gitkey/gitkey: 
Identity added: /home/ville/.ssh/keys/gitkey/gitkey (/home/ville/.ssh/keys/gitkey/gitkey)
# ssh-add -l                                 
2048 05:9c:bc:b5:cd:e4:4e:a1:53:60:57:b4:39:e4:18:d5 /home/ville/.ssh/keys/gitkey/gitkey (RSA)
# 

...但显然初始密钥不再可用,因为代理现在不同了。

我的问题是:是否可以在代理中保留登录密钥,并能够使用 向其添加更多身份ssh-add例如,我是否可以使初始代理接受其他身份,或者以某种方式将登录密钥复制到显式实例化的代理中?

答案1

这不是问题ssh-agent,而是你的Windows客户端(提供ssh-agent接口)的问题。看起来它没有实现从套接字添加另一个密钥的接口。正常情况下这应该不是问题ssh-agent

据我所知,今天唯一可能的解决方案是将密钥复制到本地主机。

有开放的上游 openssh 错误(客户端更改)请求类似的功能(支持代理列表),这应该可以解决您的问题。

相关内容