How to avoid being asked “Enter passphrase for key ” when I’m doing ssh operation on a remote host

gitssh

I'm ssh into a remote host (linux, fedora) and I want to do ssh operation(git with bitbucket) there. There is ssh-agent running on that machine,

$ ps -e|grep sh-agent
 2203 ?        00:00:00 ssh-agent

but when I want to git, it requires me to enter the passphrase

$ git pull
Enter passphrase for key '/user/wgong/home/.ssh/id_rsa': 

Note: if I operate on that machine locally, it won't ask me to enter the passphrase

Best Answer

In my opinion the best way of using ssh

Before using Git add your key to ssh-agent

Start ssh-agent if not started:

$ eval `ssh-agent -s`

Add your private key using ssh-add

$ ssh-add ~/.ssh/id_rsa_key  
Enter passphrase for /home/user/.ssh/id_rsa_key:  
Identity added: /home/user/.ssh/id_rsa_key   
(/home/user/.ssh/id_rsa_key)  

Check if the key is added (parameter is a lowercase L):

$ ssh-add -l  
2048 55:96:1a:b1:31:f6:f0:6f:d8:a7:49:1a:e5:4c:94:6f  
/home/user/.ssh/id_rsa_key (RSA)

Try to connect to your Git server:

$ ssh git.example.com

Now you can use Git without extra passphrase prompts.

Other ways

https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-password-prompt

Related Question