49
25
I'm using git bash and I setup ssh key using ssh-keygen and each time I do something with a repo git ask me for passphrase for /c/Users/jankiewj/.ssh/id_rsa
. Is there a way to disable that passphrase.
49
25
I'm using git bash and I setup ssh key using ssh-keygen and each time I do something with a repo git ask me for passphrase for /c/Users/jankiewj/.ssh/id_rsa
. Is there a way to disable that passphrase.
67
8I have to enter it again, as soon as I close git bash... is there a permanent solution? – Black – 2018-09-18T07:59:46.630
1@Black it's per bash session, I've put this in .bashrc
so each time I open git bash I get the prompt and for that session I'm all set. – jcubic – 2018-09-18T09:36:07.300
What exactly do you put in .bashrc? And where is .bashrc? – Black – 2018-09-18T09:38:20.193
Edit: nevermind, You have to create the file yourselv in ~/.bashrc
then enter the lines from your post into it and save, thats it :) thx! – Black – 2018-09-18T09:55:19.947
Instead of using the lines above, especially in the .bashrc
, I would use a script, and place it in either the .bash_profile
or .profile
.
Here is a snippet of the main portion of my .bash_profile
, it should resolve this for anyone still looking for an answer; it's similar to an answer below. At the top of the script I load up my .bashrc
, which if not applicable just leave that out. Note: you will need to change references to id_rsa
to whatever you named your private SSH key, and maybe the path.
What's with the eval
? – Det – 2019-09-07T07:07:45.623
@Det ssh-agent -s
return variables + echo in bash format, like a small script, so you need to execute it, and you need this in current context so $()
will not work. Check man ssh-agent
for -s
option. – jcubic – 2019-09-07T07:53:32.640
this only works in git bash – br4nnigan – 2020-02-13T09:45:24.937
@brannigan I use this only on Windows and it work the same in Windows WSL (linux on windows), on GNU/Linux I don't need this at all, but I have ssh key without passphrase, maybe this is the reason. On all the systems I use bash. – jcubic – 2020-02-13T14:25:42.113
10
A slightly better and permanent solution is to auto launch the ssh-agent when opening the git bash on windows. You can copy/paste the below in your .profile or .bashrc. I prefer to put it on the .profile
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
This solution was taken from this github help article
I've put my simple code into .bashrc
, how your solution different? On Windows bash each shell is independent so agent is never running when you run the shell. – jcubic – 2019-04-05T07:41:39.237
Solution works fine by putting the code into the .bashrc
. Prompting the ssh passphrase only at the first time. Safed my life. Thank you. – Ben Asmussen – 2019-06-10T19:39:27.670
thanks that's very saving my life. – gumuruh – 2019-07-13T14:38:44.683
This should really be the accepted answer as it presents a solution that is persistent and better meets what I think the OP was asking. – Richard D – 2019-07-17T17:00:35.813
What do I do if I accidentally typed the wrong password on startup? Edit: Based on https://superuser.com/a/271673/647110, you can ssh-add -D
to delete all keys.
1
Im not sure if I want to recommend it, but when you create the Key and asked to set password, just hit enter and skip the password.
Have a look at this link for how to use ssh-keygen
:
https://help.github.com/articles/working-with-ssh-key-passphrases/
Perhaps ssh-agent
can help you somehow. But not sure without knowing your current system.
5definitely not a good answer – Kennet Celeste – 2019-09-09T02:40:22.030
It was the only way to solve it on windows 10. After following all the steps of "Generating a new SSH key and adding it to the ssh-agent" github guide, it was always asking me for the passphrase. Even after added it. That behavior was breaking my maven deployment flow because at mvn release:perform
phase it tries to checkout the release tag without providing the passphrase. So only clearing the passphrase solved this issue. – Fernando Miguel Carvalho – 2019-12-17T12:47:03.067
-4
Enter this git command in your repos location "ssh-keygen -p" This will then prompt you to enter the keyfile location, the old passphrase, and the new passphrase (which can be left blank to have no passphrase). Don't enter anything in new password and it will remove passphrase
1Leaving a blank password is insecure and many corporate devs won't be able to have a blank passphrase due to restriction. It's a lame workaround, not a solution for OP issue. – cbaldan – 2019-06-02T16:06:33.430
lame perhaps, but for local use only, Tasty and expeditious™ – Jim P – 2019-09-17T17:12:19.607
This page on serverfault might help http://serverfault.com/questions/194567/how-do-i-tell-git-for-windows-where-to-find-my-private-rsa-key
– None – 2015-12-08T11:41:30.433@Radoo it didn't help. – jcubic – 2015-12-08T13:35:01.053