I have set up automatic (password less) ssh login to some servers using ssh-copy-id. ssh-agent
works only from the terminal where it was run. How do I get ssh-add
to work in all my terminals?
Naturally, I would not prefer SSH key without a passphrase.
Best Answer
If you're logging into a graphical session, arrange to start
ssh-agent
during your session startup. Some distributions already do that for you. If yours doesn't, arrange to runssh-agent
from your session startup script or from your window manager. How do do that depends on your desktop environment and your window manager. For example, if you start your window manager manually, simply replace the call tomy_favorite_wm
byssh-agent my_favorite_wm
.Do not start
ssh-agent
from.bashrc
or.zshrc
, since these files are executed by each new interactive shell. The place to startssh-agent
is in a session startup file such as.profile
or.xsession
.If you want to use the same SSH agent on all processes no matter where you logged in from, you can make it always use the same socket name, instead of using a randomly-named socket. For example, you might put this in your
~/.profile
: