Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git keeps asking me for my ssh key passphrase

Tags:

git

ssh-agent

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?

like image 880
Rogach Avatar asked Apr 05 '12 16:04

Rogach


People also ask

How do I get Git to stop asking for passphrase?

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.

Why does SSH keep asking for passphrase?

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.

How do I stop entering passphrase for SSH key?

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.


2 Answers

Once you have started the SSH agent with:

eval $(ssh-agent) 

Do either:

  1. 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.

  2. 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.

  3. To add and save your key permanently on Ubuntu (or equivalent):

      ssh-add ~/.ssh/id_rsa 
like image 176
Roberto Bonvallet Avatar answered Sep 18 '22 01:09

Roberto Bonvallet


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

like image 37
Kyle Clegg Avatar answered Sep 19 '22 01:09

Kyle Clegg