Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I test authentication with an RSA key locally?

Tags:

ssh

ssh-keys

rsa

Is there a way to check locally if you're providing the correct passphrase to an RSA key?

I recently had trouble pushing some commits to github because the push prompted for a password and then failed authentication. I verified that github had the correct public key for the id_rsa file in my ~/.ssh directory, and I verified that I could authenticate with Github (if you ssh [email protected] it will tell you you authenticated but that they don't offer shell access,) so I knew the problem was on my end, not Github's.

(I should point out that at this point I simply used git format-patch to get my commits as files, then blew away my working repository and re-cloned from Github, reapplied the patches using git am, and pushed without any trouble, so whatever the original problem was, it's fixed.)

This left me wondering, though: how would I know if an authentication problem with a remote host was me providing the wrong passphrase to my private key, or the remote host not recognizing my key? Is there a way to do a test authentication with the private key, locally, without trying to connect to a remote host?

like image 768
pjmorse Avatar asked Oct 08 '10 14:10

pjmorse


People also ask

How do I test my RSA key?

To verify that an RSA private key matches the RSA public key in a certificate you need to i) verify the consistency of the private key and ii) compare the modulus of the public key in the certificate against the modulus of the private key. If it doesn't say 'RSA key ok', it isn't OK!"


2 Answers

Or as pointed here: How can I test my ssh-keys locally without a server

You can do this:

ssh-keygen -y 

And this doesn't require any server (works great with msysgit on Windows).

like image 104
gaborous Avatar answered Sep 18 '22 14:09

gaborous


You can run ssh-add to add your key to your current ssh-agent. This will prompt for your passphrase.

Normally, when ssh-agent is running, and you add a key to it, you won't have to unlock your key any more when you connect to hosts that recognise that key. If that isn't what you want, just run ssh-add -d to remove it off your ssh-agent when you're done testing.

like image 24
Chris Jester-Young Avatar answered Sep 22 '22 14:09

Chris Jester-Young