5
8
The back story -- I've been using Git on this computer (Windows XP) for about 8 months with no problem. Suddenly, last week, it is no longer asking me for my username and password when I start Git up.
It is asking every time I try to touch my remote branches, and considering I have a passphrase rather than a password it is really annoying.
I am using the code from GitHub in my .profile
file:
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 ssh-agent > /dev/null
if [ $? -eq 0 ]; then
test_identities
else
start_agent
fi
fi
The line that is catching it is:
if [ -n "$SSH_AGENT_PID" ]; then
It thinks it's a valid entry. Needless to say, I've restarted and relogged onto my computer in many different ways, always the same. I've echo
ed out the process ID and it isn't a running process on my computer (per Task Manager).
I am have upgraded my Git (hoping it would fix the problem) and I am now running version 1.7.11-preview20120620
Any help would be greatly appreciated.
Nice! Works like a charm! – Kerry Jones – 2012-06-26T19:46:47.340
Excellent! This Works on win XP! Totally different to the one in this tute, obviously the tute has wrong code for windows: the $HOME has spaces in it and this isn't allowed and can't be manually excaped (I tried).
– None – 2013-06-23T04:17:16.560@Bezz: It can certainly be quoted:
. "$HOME/.ssh/env"
or. "$SSH_ENV"
– user1686 – 2013-06-23T13:45:34.360