如何解决 «Could not open a connection to your authentication agent»

问题:

你想使用 ssh-add 添加 ssh 密钥。它失败并显示此消息:

ssh_agent_error.txt
Could not open a connection to your authentication agent.

解决方案

ssh-agent 管理由 ssh-add 添加的密钥。即使已有实例在运行,当前 shell 实例可能不知道它 - ssh-agent 设置环境变量 SSH_AGENT_PID

为了启动新的 ssh-agent 实例,执行此命令:

start_ssh_agent.sh
eval $(ssh-agent)

如果你在服务器上使用此方法(服务器不会定期重启),随着时间的推移会累积大量运行的 ssh agent。因此你可能想不时执行 killall ssh-agent 来杀死所有你无法再使用的 ssh-agent 实例(因为你无法再访问环境变量)。


Check out similar posts by category: Linux