git - "Could not open a connection to your authentication agent",即使在 ssh-agent 启动后 ssh-add 错误

标签 git ssh gitlab

我需要添加多个ssh key ,所以我需要执行ssh-add

但是我收到错误消息Could not open a connection to your authentication agent

我读了很多帖子,比如 Could not open a connection to your authentication agenthttps://superuser.com/questions/901568/ssh-agent-could-not-open-connection

我已经通过

启动了 ssh-agent
eval ($ssh-agent -s)

输出如下: 代理 pid 13524

但还是报错:

 $ ssh-add ~/.ssh/id_rsa
 Could not open a connection to your authentication agent.

我也设置了

git config --global url."https://".insteadOf git://

然后我回显了一些变量并得到了这个:

echo $SSH_AGENT_PID
12340 
echo $SSH_AUTH_SOCK 
/tmp/ssh-ZbRZr10908/agent.10908

PS:我用的是Windows 7,下属公司网络。

最佳答案

我在网上尝试了很多解决方案,但都没有用。我进行了更多研究,发现以下命令有效。

  1. sudo ssh-agent bash
  2. ssh-add /home/user/.ssh/id_rsa

关于git - "Could not open a connection to your authentication agent",即使在 ssh-agent 启动后 ssh-add 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33227125/

相关文章:

Gitlab合并请求快进合并

windows - 如何在通过文件 ://protocol? 指定的 Remote 上正确设置 Hook

git - arc diff 禁用测试计划 'differential.require-test-plan-field' 不起作用

git - 去除悬挂 Blob 的最安全方法是什么

Git 服务器拒绝访问

variables - 是否可以在用户定义变量中使用预定义变量:

git - 将存储库从 Github 迁移到自托管 Gitlab 时更新和修复 LFS

git - 在 Windows 上设置 autocrlf = input 有什么害处?

linux - bash 脚本中的命令无法正常工作

linux - 通过ssh连接到另一台服务器后如何在shell脚本中下载文件?