Skip to main content
Nordlys logo, a drawing of two gray mountains with green northern lights in the background TIL

Back to all TILs

Verify your SSH key passphrase

Published on by Brie Carranza · 1 min read

Table of Contents

Show more

I was working through The New Stack’s guide to signing git commits with SSH keys and I needed to make sure that the passphrase I was using was the right one. I wanted an elegant way to check this and I found:

ssh-keygen -y

From the man page, we see that ssh-keygen -y does this:

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

If you supply an incorrect passphrase, you’ll see something like this:

# ssh-keygen -f til-brie-dev -y
Enter passphrase:
Load key "til-brie-dev": incorrect passphrase supplied to decrypt private key

If things go well, you’ll see the corresponding public key printed, probably in a a string that starts ssh-rsa and contains the signature blob with an optional comment. 🎉

If there’s no passphrase set, you won’t be prompted.

Cool!