0

I am having a server process which is using a passphrase protected SSH key. Currently I log in via SSH to give the key every time the process is restarted. I do:

eval `ssh-agent`
ssh-add mykey
# Enter passphrase 
# start my server process

I'd like to change this process, so that I enter SSH passphrase only once, after the server is rebooted. Then the key would be accessible by all processes of a certain UNIX user on that server until the server is restarted again.

How could I set up such setup? Any other ideas how to make this process more smooth?

Ubuntu Server 12.04.

1 Answer 1

2

So, you want a certain UNIX user on that server enter SSH passphrase only once, and want that SSH passphrase will be good until the server is restarted again, right? Anything more than that?

If no more than that, then Keychain is your answer.

Keychain is an OpenSSH key manager, typically run from ~/.bash_profile. When keychain is run, it checks for a running ssh-agent, otherwise it starts one. It saves the ssh-agent environment variables to ~/.keychain/\${HOSTNAME}-sh, so that subsequent logins and non-interactive shells such as cron jobs can source the file and make passwordless ssh connections. In addition, when keychain runs, it verifies that the key files specified on the command-line are known to ssh-agent, otherwise it loads them, prompting you for a password if necessary.

With Keychain, I only need to type in my SSH passphrase once after my box is rebooted.

1
  • Awesome! Exactly what I was looking for. Thanks xpt. Mar 14, 2013 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .