3

Currently every time I start up terminal I get prompted the following:

Last login: Mon Nov 28 21:32:16 on ttys000

Agent pid 2733

Enter passphrase for /Users/my_name/.ssh/id_rsa:

Could you please guide me on how I can avoid having to enter a passphrase everytime?

HosseinK
  • 877
  • 2
  • 10
  • 16

3 Answers3

6

You could add your passphrase to your keychain:

ssh-add -K ~/.ssh/id_rsa

Or you can add it in your ~/.ssh/config:

Host *
UseKeychain yes
Jules
  • 2,885
  • 1
  • 25
  • 33
4

You probably wrote to your ~/.bashrc lines

`eval ssh-agent`
ssh-add

or something like this. This means that it will start a new ssh-agent for every shell you open, which is certainly not what you want. The agent should start when you open your Xsession (~/.xsession), or you should check if the agent is running before running a new one:

[ -z $SSH_AUTH_SOCK ] && `eval ssh-agent` && ssh-add
Jakuje
  • 20,643
  • 11
  • 53
  • 62
  • Perfect. This worked! and you were right, in my .bash_profile I had: eval "$(ssh-agent -s)" ssh-add -K ~/.ssh/id_rsa – HosseinK Nov 29 '16 at 21:35
1

You can use ssh-agent. The man-page says :

ssh-agent is a program to hold private keys used for public key authenti‐ cation (RSA, DSA, ECDSA, Ed25519). ssh-agent is usually started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program. Through use of environment variables the agent can be located and automatically used for authentication when logging in to other machines using ssh(1).

On further reading you can see :

The agent initially does not have any private keys. Keys are added using ssh-add(1). When executed without arguments, ssh-add(1) adds the files ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for the passphrase on the terminal if it has one or from a small X11 program if running under X11. If neither of these is the case then the authenti‐ cation will fail. It then sends the identity to the agent. Several identities can be stored in the agent; the agent can automatically use any of these identities. ssh-add -l displays the identities currently held by the agent.

sjsam
  • 19,686
  • 3
  • 43
  • 88