Bash SSH – Start a System-Wide SSH Agent

bashsshssh-agent

Currently, I have commands to start the SSH agent in my .bashrc file. The trouble is that this only works in a particular terminal – each time I open a terminal, I'm asked for my private key's passphrase.

Is there a way to open the SSH agent so that it can be used for multiple terminals without having to re-enter the passphrase each time?

Best Answer

The agent to use is determined by SSH_AUTH_SOCK environment variable (and the agent process itself - by SSH_AGENT_PID), so you can save those to files in your startup scripts (execute ssh-agent in them as intended user) and pass to login shells in .bashrc script. This will give you not system-wide, but user-wide agent. Also if you use X on this machine, you can add ssh-agent to the terminal which starts X, the variables will be inherited by shells called from X. Your question doesn't specify enough details of your environment to be more specific.

Related Question