12.04LTS – 无法打开与您的身份validation代理的连接

我正在为新的Linode Ubuntu 12.04LTS部署添加ssh身份validation。 我按照他们的指导 ,直到我需要用我现在刚刚添加的ssh密钥ssh到框中,但我反而得到:

"Error: agent admitted failure to sign using the key" 

这很好, Ubuntu OpenSSH指南说,你需要做的就是运行

 ssh-add 

在服务器上,你会成为金。 除了当我这样做,我得到

 Could not open a connection to your authentication agent. 

我仔细检查了一下进程,确实看起来好像ssh-agent已经运行了(实际上是两次,因为我试过了eval技巧 ,根本不起作用):

 alex@mybox:~$ ps aux | grep ssh root 2645 0.0 0.1 49948 776 ? Ss Mar13 0:00 /usr/sbin/sshd -D alex 16989 0.0 0.0 12492 324 ? Ss Mar13 0:00 ssh-agent root 18986 0.0 0.7 73360 3564 ? Ss 09:03 0:00 sshd: alex [priv] alex 19119 0.0 0.3 73360 1676 ? S 09:03 0:00 sshd: alex@pts/0 alex 19785 0.0 0.0 12492 316 ? Ss 09:59 0:00 ssh-agent root 20026 0.0 0.7 73360 3568 ? Ss 10:02 0:00 sshd: alex [priv] alex 20184 0.0 0.3 73360 1680 ? S 10:03 0:00 sshd: alex@pts/1 alex 20325 0.0 0.1 9384 924 pts/1 S+ 10:13 0:00 grep --color=auto ssh 

正如我所提到的,eval方法设法使ssh-add工作一次,但是当我再次尝试login时,系统报告了上面列出的同样的错误。 我现在也有两个ssh-agent实例。

解决这个问题的正确方法是什么?

尝试启动当前bash会话的ssh-agent。 这是你需要做的。

  1. testing你的当前env的ssh-agent PID:

     env | grep ^SSH 
  2. 如果你没有注意到,那么为当前的env启动ssh-agent:

     exec ssh-agent bash 
  3. 现在尝试添encryption钥:

     ssh-add 

确保将SSH_AGENT_PID环境variables设置为SSH代理的PID,并将SSH_AUTH_SOCK设置为代理套接字path(通常位于/tmp目录中,例如: /tmp/ssh-wpNhPp3007/agent.3007

ssh-add可以使用这些variables来添加你的密钥。

您也可以使用以下语法:

 ssh-agent sh -c 'ssh-add && echo Do some stuff here.' 

您的问题是在客户端上 ,而不是在服务器上。 运行sshd的系统不关心ssh-add / ssh-agent。 它只是检查客户端系统是否能够进行授权数字签名。 不pipe这个签名是由ssh,ssh-agent还是智能卡完成的,都没有什么不同。

如果你不使用其中一个标准文件(例如〜/ .ssh / id_rsa_newbox),那么你必须告诉ssh( -i ~/.ssh/id_rsa_newbox) or ssh-agent ( ssh- -i ~/.ssh/id_rsa_newbox) or ssh-agent ( / .ssh / id_rsa_newbox`)来使用这个非标准文件。