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

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

You can now use git without passing questions

Other ways