Git always request a passphrase for a key

I had a problem using git from time to time.

When I use the git pull origin my_branch or git fetch or git push origin my_branch , git always asks for the password for the passphrase. And I did not understand why?

I hope someone can explain the reason and the way to avoid entering the password every time.

 $ git fetch Enter passphrase for key '/home/khanhpn/.ssh/id_rsa': 
+14
git github
source share
2 answers

As Nasruddin says, this is because your key is encrypted with a passphrase so that others cannot read it.

The most convenient way to use passphrases is to use ssh-agent to start the authentication agent (which runs in the background):

 $ eval "$(ssh-agent)" Agent pid 44304 

... and then use ssh-add register your key with the agent so that it is automatically used for subsequent SSH connections:

 $ ssh-add ~/.ssh/id_rsa Enter passphrase for /home/khanhpn/.ssh/id_rsa: 

You will be prompted for a password when ssh-add started, but you will not need to do this again while ssh-agent running.

You can find more information about GitHub . Also note that you will have to do this every time you log in, so you can add the eval "$(ssh-agent)" step eval "$(ssh-agent)" to your .profile script.

+43
source share

This is because your SSH private key is password protected. You can delete it with this command ( not recommended, since anyone can copy your key and use it to access your repositories / account ):

 $ ssh-keygen -p Enter file in which the key is (/path/to/your/.ssh/key): 

enter the current passphrase when prompted:

 Enter old passphrase: Key has comment 'rsa w/o comment' 

leave blank if you want to remove the passphrase when prompted:

 Enter new passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved with the new passphrase. 
+8
source share

All Articles