我遇到了以下错误:
$ 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.
我尝试添加密钥,但出现以下错误:
$ ssh-add ~/.ssh/id_rsa.pub
Could not open a connection to your authentication agent.
我在尝试下载Git存储库时出错:
无法打开与身份验证代理的连接。ssh添加退出代码2
要消除此错误,请执行以下操作:
使用无密码私钥时,既不需要ssh代理,也不需要ssh add。请参阅将私钥添加到docker文件中的ssh代理。
如果处理得当(使用后删除),无密码私钥不需要使系统不安全。也许这也有助于解决Heroku问题?
这个“把戏”什么时候最重要?在Dockerfile中!
我必须使用无密码私钥来获取Dockerfile以克隆Git存储库,因为在Dockerfile运行期间,无法在shell中输入密码。请参阅Dockerfile:clone repo with passwordless private key。错误:例如,“身份验证代理”或“read_passphrase:无法打开/dev/tty”。最近,还可以考虑使用部署令牌访问Git存储库,而无需手动输入密码。
这将只在您第一次需要时运行SSH代理并进行身份验证,而不是每次打开Bash终端时。它可以用于一般使用SSH的任何程序,包括SSH本身和scp。只需将其添加到/etc/profile.d/ssh-helper.sh:
ssh-auth() {
# Start the SSH agent only if not running
[[ -z $(ps | grep ssh-agent) ]] && echo $(ssh-agent) > /tmp/ssh-agent-data.sh
# Identify the running SSH agent
[[ -z $SSH_AGENT_PID ]] && source /tmp/ssh-agent-data.sh > /dev/null
# Authenticate (change key path or make a symlink if needed)
[[ -z $(ssh-add -l | grep "/home/$(whoami)/.ssh/id_rsa") ]] && ssh-add
}
# You can repeat this for other commands using SSH
git() { ssh-auth; command git "$@"; }
注:这是对这个问题的回答,它已经与这个问题合并。这个问题是针对Windows 7的,这意味着我的答案是针对Cygwin/MSYS/MSYS2的。这一点似乎适用于某些Unix,我不希望SSH代理需要这样管理。
放大n3o对Windows 7的回答。。。
我的问题是确实没有设置一些必需的环境变量,而n3o是正确的,ssh-agent会告诉您如何设置这些环境变量,但实际上并没有设置它们。
由于Windows不允许您执行“eval”,因此以下是替代方法:
将ssh代理的输出重定向到批处理文件
ssh-agent > temp.bat
现在使用记事本等文本编辑器编辑temp.bat。对于前两行中的每一行:
在行首插入单词“set”和空格。删除第一个分号和后面的所有内容。
现在删除第三行。您的temp.bat应该如下所示:
set SSH_AUTH_SOCK=/tmp/ssh-EorQv10636/agent.10636
set SSH_AGENT_PID=8608
运行temp.bat。这将设置ssh add工作所需的环境变量。