44

I think I've forgotten my RSA passphrase again.

Is there a way to have my local command line prompt me for it so I can check if I at least what I remember it as is correct, so I don't needlessly change it?

Next time I'm writing it on a post-it ;)

quack quixote
  • 43,504
joachim
  • 818

3 Answers3

66

Use:

ssh-keygen -y

-y      This option will read a private OpenSSH format file and
        print an OpenSSH public key to stdout.

Example:

$ ssh-keygen -y -f ~/.ssh/id_rsa_file

This will prompt to enter the passphrase. Given a wrong passphrase it will say "load failed" otherwise it will print the OpenSSH public key to stdout.

bPratik
  • 189
Al Conrad
  • 761
11

Try ssh-keygen -p:

-p      Requests changing the passphrase of a private key file instead of
        creating a new private key.  The program will prompt for the file
        containing the private key, for the old passphrase, and twice for
        the new passphrase.
blahdiblah
  • 5,501
0

Linux or Windows

If you lose your SSH key passphrase, there's no way to recover it. You'll need to generate a brand new SSH keypair or switch to HTTPS cloning so you can use a personal access token instead.

Mac

If you configured your SSH passphrase with the macOS keychain, you may be able to recover it.

  • In Finder, search for the Keychain Access app.
  • In Keychain Access, search for SSH.
  • Double-click on the entry for your SSH key to open a new dialog box.
  • In the lower-left corner, select Show password.
  • You'll be prompted for your administrative password. Type it into the "Keychain Access" dialog box.
  • Your password will be revealed.

Reference: https://docs.github.com/en/authentication/troubleshooting-ssh/recovering-your-ssh-key-passphrase