How do you test a public/private DSA keypair?

Loki picture Loki · Nov 8, 2008 · Viewed 160k times · Source

Is there an easy way to verify that a given private key matches a given public key? I have a few *.puband a few *.key files, and I need to check which go with which.

Again, these are pub/key files, DSA.

I would really prefer a one-liner of some sort...

Answer

Loki picture Loki · Nov 8, 2008

I found a way that seems to work better for me:

ssh-keygen -y -f <private key file>

That command will output the public key for the given private key, so then just compare the output to each *.pub file.