Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep being prompted to enter passphrase for .ssh/id_rsa

Tags:

git

bash

ssh

cygwin

I followed the tutorial here to set up ssh for github in cygwin on Window 7. However, every time I do git push origin master, I keep being prompted the following:

Enter passphrase for /cygdrive/c/Users/mynameis/.ssh/id_rsa:

This is so annoying because it beats the purpose of setting up ssh in the first place. I don't understand why it keeps prompting me for a password because when I did the same thing with my Mac and everything just worked fine and smooth.

I tried other solutions like: adding eval ssh-agent -sinto my .bashrc . But the problem still remains. I suspect the problem has to do with ssh-agent or ssh-add in cygwin on Window 7. How can I get around this problem ?

like image 378
mynameisJEFF Avatar asked Feb 16 '15 01:02

mynameisJEFF


1 Answers

Add the following to your ~/.bash_profile. When bash starts, this does two things: 1. starts the ssh-agent (otherwise it might spawn and die for each push/pull) and 2. tells the agent to remember your passphrase. In some Linux distributions, this happens automatically, unfortunately that isn't the case with Cygwin.

## only ask for my SSH key passphrase once!
#use existing ssh-agent if possible
if [ -f ${HOME}/.ssh-agent ]; then
   . ${HOME}/.ssh-agent > /dev/null
fi
if [ -z "$SSH_AGENT_PID" -o -z "`/usr/bin/ps -a|/usr/bin/egrep \"^[ ]+$SSH_AGENT_PID\"`" ]; then
   /usr/bin/ssh-agent > ${HOME}/.ssh-agent
   . ${HOME}/.ssh-agent > /dev/null
fi
ssh-add ~/.ssh/id_rsa

See also:

  • Using passwordless login on PuTTY and Cygwin using Keys over SSH and SCP
  • Or if you're using PoshGit... Configure Git in PowerShell So You Don’t Have to Enter Your Password All the Damn Time
like image 131
Shaun Luttin Avatar answered Oct 18 '22 03:10

Shaun Luttin