How to check if a RSA public / private key pair matched

Ryan asked:

I have two files, id_rsa and, what command can be used to validate if they are the valid pair.

My answer:

If they’re on your local system, stick in your $HOME/.ssh/authorized_keys and ssh to localhost using the id_rsa key. If it works, then they match.

cat $HOME/.ssh/ >> $HOME/.ssh/authorized_keys
ssh -i $HOME/.ssh/id_rsa localhost

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.