What is the purpose of passphrase when I generate public and private keys using ssh-keygen?

I'm fairly new to all the SSH business. I have some basic idea about that using SSH public and private keys allows me to be identified and authorized by remote SSH server without having to have a password transferred over the Internet. But when I generate the keys, it also offers to type in optionally a passphrase. What is this passphrase for? What is the pros and cons to use it?

1 Answer 1


To encrypt your keys. So if an attacker get's your private/public key, it can't do anything with them.

  • 2
    To amplify: Imagine you have the private-key pair on a laptop. You lose the laptop. A thief gets access to your private key and can impersonate you and access all the computers you have access to. A passphrase helps to prevent this. Jan 15, 2012 at 9:42
  • If I store the private key file on a USB drive which is shared with some friends sometimes, do I need to further protect the file or is the passphrase sufficient?
    – qazwsx
    Jan 17, 2012 at 1:11
  • depends on the passphrase...and the friends... :)
    – rogerdpack
    Feb 16, 2022 at 3:36

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.