I created keys as instructed in the github tutorial, registered them with github, and tried using ssh-agent explicitly — yet git continues to ask me for my passphrase every time I try to do a pull or a push.
What could be the cause?
Entering Git Username and Password in Remote URL To prevent Git from asking for your username and password, you can enter the login credentials in the URL as shown. The main drawback of this method that your username and password will be saved in the command in the Shell history file.
There may be times in which you don't want the passphrase stored in the keychain, but don't want to have to enter the passphrase over and over again. This will ask you for the passphrase, enter it and it will not ask again until you restart.
Use ssh-add to add the keys to the list maintained by ssh-agent. After you add a private key password to ssh-agent, you do not need to enter it each time you connect to a remote host with your public key.
Once you have started the SSH agent with:
eval $(ssh-agent)
Do either:
To add your private key to it:
ssh-add
This will ask you your passphrase just once, and then you should be allowed to push, provided that you uploaded the public key to Github.
To add and save your key permanently on macOS:
ssh-add -K
This will persist it after you close and re-open it by storing it in user's keychain.
To add and save your key permanently on Ubuntu (or equivalent):
ssh-add ~/.ssh/id_rsa
This has been happening to me after restarts since upgrading from OS X El Capitan (10.11) to macOS Sierra (10.12). The ssh-add
solution worked temporarily but would not persist across another restart.
The permanent solution was to edit (or create) ~/.ssh/config
and enable the UseKeychain
option.
Host * UseKeychain yes
Related: macOS keeps asking my ssh passphrase since I updated to Sierra
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With