SSH: How to generate public key from private key

I am in the process of switching computers.

I have a private key to one of my aws boxes, but the box no longer has a copy of the public key. So I can’t log in.

The trick is: I have to find the public key using the private key I have locally. The command is

ssh-keygen -y

It will prompt you for the file you want to get the public key from.

I got the public key, went into the box using my old machine, and put the public key into the authorized_keys section.

Yay!