![如何处理登录屏幕上弹出的 .ssh-agent?](https://linux22.com/image/1095592/%E5%A6%82%E4%BD%95%E5%A4%84%E7%90%86%E7%99%BB%E5%BD%95%E5%B1%8F%E5%B9%95%E4%B8%8A%E5%BC%B9%E5%87%BA%E7%9A%84%20.ssh-agent%EF%BC%9F.png)
我在 Ubuntu 12.04 上通过终端使用 ssh 密钥密码设置 git,帮助.GitHub:“您可以通过将以下内容添加到您的 ~/.profile 或 ~/.bashrc 文件来在打开 bash 时自动运行 ssh-agent”我添加了 ~/.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
过了一会儿,我重启了电脑。现在,每当我尝试以唯一用户(而不是访客)身份登录(即在登录屏幕上输入密码并按 Enter 键)时,屏幕就会变黑,并弹出一个窗口要求我输入/.ssh/rsa_id passphrase
.
当我输入 GitHub 的密码时,Ubuntu 让我回到登录界面,一切从头开始。我知道的唯一其他登录方式是以访客身份登录。
发生了什么事?我该如何解决这个问题?