I have generated an RSA public / private key pair using ssh-keygen. However, I am prompted to enter the password to unlock it the first time it is used each session. How can I automatically have it unlocked after login?

Even better: since this is running on an Ubuntu server, it would be great if it was never locked at all - that way the automated daemons that need it would not require manual intervention to use it.

  • Possible duplicate: askubuntu.com/questions/36255/… – Kris Harper Nov 3 '11 at 1:51
  • 1
    @root45: How is that a duplicate? It doesn't seem to be the same question at all. – Nathan Osman Nov 3 '11 at 1:55
  • You're both being asked to unlock your key file each time you SSH into a server. Sorry, they seemed to be very similar or the same to me, but maybe I'm misunderstanding one or the other or both. – Kris Harper Nov 3 '11 at 2:09

I may be mistaken here, but it sounds like what you're trying to do is to not need to unlock your key every time it is used?

If that's the case, it seems like the easiest solution would be to just not create a passphrase while creating the key. i.e. run


and when it asks for a passphrase, just press enter twice. I apologize if this is too simplistic, but it's what I've always done when creating keys so I don't need to unlock them. Hope it helps!

| improve this answer | |
  • 3
    That is not that kind of thing that improves security. A user could just copy the private key and access the other computer(s) easily. – Paradiesstaub Dec 11 '11 at 20:54
  • 1
    I agree with Paradiesstaub, this accepted answer present security vulnerabilities! – greydet Oct 11 '13 at 17:08
  • That's certainly true, but hopefully there is some sort of encryption on the disk or at least on /home/user. If not, I agree that it's a pretty significant vulnerability, but that's typically the tradeoff for convenience, no? – jat255 Oct 11 '13 at 20:58

For reusage of encrypted key use ssh-agent. It prints some output containing environment variables that you have to export. Then add keys with ssh-add.

You have to unlock your key only once until ssh-agent is running.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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