Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Awesome! Exactly what I was looking for. Thanks xpt. –  Mikko Ohtamaa Mar 14 '13 at 17:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.