我目前正在使用 Cywin,并且之前已经进行过设置。重新安装并重新进行设置后,它不再工作。
我按照此处的说明进行操作
https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git
我使用以下代码修改了 .bashrc
SSH_ENV="$HOME/.ssh/environment"
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV"
echo succeeded
chmod 600 "$SSH_ENV"
. "$SSH_ENV" > /dev/null
ssh-add
}
# test for identities
function test_identities {
# test whether standard identities have been added to the agent already
ssh-add -l | grep "The agent has no identities" > /dev/null
if [ $? -eq 0 ]; then
ssh-add
# $SSH_AUTH_SOCK broken so we start a new proper agent
if [ $? -eq 2 ];then
start_agent
fi
fi
}
# check for running ssh-agent with proper $SSH_AGENT_PID
if [ -n "$SSH_AGENT_PID" ]; then
ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null
if [ $? -eq 0 ]; then
test_identities
fi
# if $SSH_AGENT_PID is not properly set, we might be able to load one from
# $SSH_ENV
else
if [ -f "$SSH_ENV" ]; then
. "$SSH_ENV" > /dev/null
fi
ps -ef | grep "$SSH_AGENT_PID" | grep -v grep | grep ssh-agent > /dev/null
if [ $? -eq 0 ]; then
test_identities
else
start_agent
fi
fi
我在 ~/.ssh/config 中的配置文件如下
Host bitbucket.org
IdentityFile ~/.ssh/id_rsa
以前这按预期工作。当我启动 Cygwin 时,系统会提示我输入密码,然后在执行 ssh-add -l 时,我会显示我添加的身份。
但是,现在它出现并说
正在初始化新的 SSH 代理...
成功
然后它就会带我进入提示符。
执行 ssh-add -l 时,它不显示任何身份。
我想知道 bash 代码中是否存在可能导致此问题的错误。
最佳答案
由于您没有表明系统会提示您输入密码,因此您的 ssh key 有问题。如果我将 ~/.ssh/id_rsa 移动到另一个文件,我会得到同样的结果。
您可能必须重新生成 ssh key 。
关于Git SSH 访问设置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16883872/