windows remember git ssh passphrase in mingw32 shell
This pro Tip explain how to use ssh-agent to remember the passphrase while you are working with git MySysGit under windows.
After following this steps you do only need to enter your passphrase once per os session for your ssh communication to github.
Steps:
- open you mingw32 git bash from context menu
- create the file .bashrc touch ~/.bashrc
- navigate to your mingw git assigned homefolder
- open .bashrc with an texteditor
- add the code above to this file
SSH_ENV=$HOME/.ssh/environment
function startagent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSHENV}
echo succeeded
chmod 600 ${SSHENV}
. ${SSHENV} > /dev/null
/usr/bin/ssh-add;
}
if [ -f "${SSHENV}" ]; then
. ${SSHENV} > /dev/null
#ps ${SSHAGENTPID} doesn't work under cywgin
ps -ef | grep ${SSHAGENTPID} | grep ssh-agent$ > /dev/null || {
startagent;
}
else
startagent;
fi
The script commands will check if ssh agent is allready running. If not it will start the agent and ask you for your passphrase for your ssh key. If you close your shell the ssh-agent will stay in background for further connection authorisations.