Contributed by Fabien Loudet, Linux SysAdmin at Rosetta Stone
Tired of always having to enter your SSH key passphrase when logging in to remote machines?
Here comes ssh-agent
. Enter the passphrase once and it will keep it in memory for you
Using ssh-agent in your shell session:
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-hZQhwQlxahPX/agent.1833; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1834; export SSH_AGENT_PID;
echo Agent pid 496;
Copy/paste the 2 first lines from above:
$ SSH_AUTH_SOCK=/tmp/ssh-hZQhwQlxahPX/agent.1833; export SSH_AUTH_SOCK;
$ SSH_AGENT_PID=1834; export SSH_AGENT_PID;
Register your key and enter your password for the last time of this session:
$ ssh-add .ssh/id_rsa
Enter passphrase for .ssh/id_rsa:
Identity added: .ssh/id_rsa (.ssh/id_rsa)
And now SSH auth will not ask you for the passphrase anymore
BONUS: list your keys with:
$ ssh-add -l
@Kr3m - when you do ...
... it sets the
SSH_AUTH_SOCK
andSSH_AGENT_PID
shell environment variables. These are important and if they don't exist; then yourssh
command won't know thatssh-agent
is running. You should include something like ...... into your
.profile
file. There's variations on this method (see google searches); however, the key point is that you will loose your connection to yourssh-agent
session once you exit your terminal and while it's technically still running; yourssh
program won't know that.This is a pure shell issue and not an ssh subsystem issue.