无法打开与身份验证代理的连接

本文翻译自:Could not open a connection to your authentication agent

I am running into this error of: 我遇到以下错误:

$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
!  Your key with fingerprint b7:fd:15:25:02:8e:5f:06:4f:1c:af:f3:f0:c3:c2:65 is not authorized to access bitstarter.

I tried to add the keys and I get this error below: 我试图添加密钥,但在下面出现此错误:

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

#1楼

参考:https://stackoom.com/question/1CshF/无法打开与身份验证代理的连接


#2楼

MsysGit or Cygwin MsysGit或Cygwin

If you're using Msysgit or Cygwin you can find a good tutorial at SSH-Agent in msysgit and cygwin and bash : 如果您使用的是Msysgit或Cygwin,则可以在SSH-Agent的msysgit和cygwin和bash中找到一个很好的教程:

  1. Add a file called .bashrc to your home folder. 将一个名为.bashrc的文件添加到您的主文件夹中。

  2. Open the file and paste in: 打开文件并粘贴:

     #!/bin/bash eval `ssh-agent -s` ssh-add 
  3. This assumes that your key is in the conventional ~/.ssh/id_rsa location. 假设您的密钥位于常规的~/.ssh/id_rsa位置。 If it isn't, include a full path after the ssh-add command. 如果不是,请在ssh-add命令之后包含完整路径。

  4. Add to or create file ~/.ssh/config with the contents 添加或创建文件~/.ssh/config及其内容

     ForwardAgent yes 

    In the original tutorial the ForwardAgent param is Yes , but it's a typo. 在原始教程中, ForwardAgent参数为Yes ,但这是一个错字。 Use all lowercase or you'll get errors. 使用所有小写字母,否则会出错。

  5. Restart Msysgit. 重新启动Msysgit。 It will ask you to enter your passphrase once, and that's it (until you end the session, or your ssh-agent is killed.) 它会要求您输入一次密码,就是这样(直到您结束会话,或者您的ssh-agent被杀死。)

Mac/OS X Mac / OS X

If you don't want to start a new ssh-agent every time you open a terminal, check out Keychain . 如果您不想在每次打开终端时都启动新的ssh-agent,请查看Keychain I'm on a Mac now, so I used the tutorial ssh-agent with zsh & keychain on Mac OS X to set it up, but I'm sure a Google search will have plenty of info for Windows. 我现在在Mac上,因此我在Mac OS X上使用了带有ssh-agent和zsh&keychain的教程来进行设置,但是我敢肯定Google搜索会为Windows提供很多信息。

Update : A better solution on Mac is to add your key to the Mac OS Keychain: 更新 :在Mac上更好的解决方案是将密钥添加到Mac OS钥匙串:

ssh-add -K ~/.ssh/id_rsa

Simple as that. 就那么简单。


#3楼

Let me offer another solution. 让我提供另一个解决方案。 If you have just installed Git 1.8.2.2 or thereabouts, and you want to enable SSH, follow the well-writen directions . 如果您刚刚安装的Git 1.8.2.2点左右,并要启用SSH,跟随良好writen 方向

Everything through to Step 5.6 where you might encounter a slight snag. 直到步骤5.6的所有内容,您都可能遇到轻微的障碍。 If an SSH agent is already be running you could get the following error message when you restart bash 如果SSH代理已经在运行,则在重新启动bash时可能会收到以下错误消息

Could not open a connection to your authentication agent

If you do, use the following command to see if more than one ssh-agent process is running 如果这样做,请使用以下命令查看是否正在运行多个ssh-agent进程

ps aux | grep ssh

If you see more than one ssh-agent service, you will need to kill all of these processes. 如果看到多个ssh-agent服务,则将需要终止所有这些进程。 Use the kill command as follows (the PID will be unique on your computer) 如下使用kill命令(PID在您的计算机上将是唯一的)

kill <PID>

Example: 例:

kill 1074

After you have removed all of the ssh-agent processes, run the px aux | 删除所有ssh-agent进程后,运行px aux |。 grep ssh command again to be sure they are gone, then restart Bash. 再次使用grep ssh命令确保它们消失了,然后重新启动Bash。

Voila, you should now get something like this: 瞧,您现在应该得到以下内容:

Initializing new SSH agent...
succeeded
Enter passphrase for /c/Users/username/.ssh/id_rsa:

Now you can continue on Step 5.7 and beyond. 现在,您可以继续执行步骤5.7及以后的步骤。


#4楼

Could not open a connection to your authentication agent 无法打开与身份验证代理的连接

To resolve this error: 解决此错误的方法:

bash: 重击:

$ eval `ssh-agent -s`

tcsh: tcsh:

$ eval `ssh-agent -c`

Then use ssh-add as you normally would. 然后像往常一样使用ssh-add


Hot Tip: 热门提示:

I was always forgetting what to type for the above ssh-agent commands, so I created an alias in my .bashrc file like this: 我总是忘记为上面的ssh-agent命令键入什么,因此我在.bashrc文件中创建了一个别名,如下所示:

alias ssh-agent-cyg='eval `ssh-agent -s`'

Now instead of using ssh-agent , I can use ssh-agent-cyg 现在,而是采用ssh-agent ,我可以使用ssh-agent-cyg

Eg 例如

$ ssh-agent-cyg
SSH_AUTH_SOCK=/tmp/ssh-n16KsxjuTMiM/agent.32394; export SSH_AUTH_SOCK;
SSH_AGENT_PID=32395; export SSH_AGENT_PID;
echo Agent pid 32395;
$ ssh-add ~/.ssh/my_pk

Original Source of fix: 修复程序的原始来源:

http://cygwin.com/ml/cygwin/2011-10/msg00313.html http://cygwin.com/ml/cygwin/2011-10/msg00313.html


#5楼

I faced the same problem for Linux, and here is what I did: 我在Linux上遇到了同样的问题,这是我所做的:

Basically, the command ssh-agent starts the agent, but it doesn't really set the environment variables for it to run. 基本上,命令ssh-agent启动代理,但实际上并没有设置环境变量以使其运行。 It just outputs those variables to the shell. 它只是将这些变量输出到外壳。

You need to: 你需要:

eval `ssh-agent`

and then do ssh-add. 然后执行ssh-add。 See Could not open a connection to your authentication agent . 请参阅无法打开与身份验证代理的连接


#6楼

Did You Start ssh-agent ? 您是否已启动ssh-agent

You might need to start ssh-agent before you run the ssh-add command: 在运行ssh-add命令之前,您可能需要启动ssh-agent

eval `ssh-agent -s`
ssh-add

Note that this will start the agent for msysgit Bash on Windows . 请注意,这将启动Windows上的msysgit Bash代理。 If you're using a different shell or operating system, you might need to use a variant of the command, such as those listed in the other answers . 如果您使用的是其他Shell或操作系统,则可能需要使用命令的变体,例如其他答案中列出的命令。

See the following answers: 请参阅以下答案:

  1. ssh-add complains: Could not open a connection to your authentication agent ssh-add抱怨:无法打开与身份验证代理的连接
  2. Git push requires username and password (contains detailed instructions on how to use ssh-agent) Git push需要用户名和密码 (包含有关如何使用ssh-agent的详细说明)
  3. How to run (git/ssh) authentication agent? 如何运行(git / ssh)身份验证代理? .
  4. Could not open a connection to your authentication agent 无法打开与身份验证代理的连接

To automatically start ssh-agent and allow a single instance to work in multiple console windows, see Start ssh-agent on login . 要自动启动ssh-agent并允许单个实例在多个控制台窗口中工作,请参阅登录时启动ssh-agent

Why do we need to use eval instead of just ssh-agent ? 为什么我们需要使用eval而不是ssh-agent

To find out why, see Robin Green's answer . 要找出原因,请参阅Robin Green的答案

Public vs Private Keys 公钥与私钥

Also, whenever I use ssh-add , I always add private keys to it. 另外,每当我使用ssh-add ,我总是向其添加私钥。 The file ~/.ssh/id_rsa.pub looks like a public key, I'm not sure if that will work. ~/.ssh/id_rsa.pub文件看起来像一个公钥,我不确定是否可以使用。 Do you have a ~/.ssh/id_rsa file? 您是否有~/.ssh/id_rsa文件? If you open it in a text editor, does it say it's a private key? 如果在文本编辑器中将其打开,是否表示它是私钥?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值