「ssh-agent」- Could not open a connection to your authentication agent.

  CREATED BY JENKINSBOT

问题描述

当执行 ssh-add 命令时,产生如下错误:

# ssh-add /path/to/id_ras
Could not open a connection to your authentication agent.

问题原因

在环境变量中,相关参数未设置,导致程序无法找到 ssh-agent 服务。需要设置的变量如下:

# ssh-agent -s
SSH_AUTH_SOCK=/tmp/ssh-SUEIyA5guxOn/agent.3917; export SSH_AUTH_SOCK;
SSH_AGENT_PID=3918; export SSH_AGENT_PID;
echo Agent pid 3918;

解决方案

# source <(ssh-agent -s) >/dev/null

参考文献

git – Could not open a connection to your authentication agent – Stack Overflow