Creating RSA public keys from private keys

Generating a public RSA key is a pretty simple task. More often than not, keys will be generated in pairs. But sometimes you will be given an RSA private key and you will need to create your own public key from it. (For example, when using Amazon EC2). Fortunately, you only need to remember a quick one-liner to do so:

$ ssh-keygen -y -f mykey.pem > mykey.pub

The -y flag tells ssh-keygen to create a public key based off of the private key passed to the -f flag. It's really that simple. by default, this will simple print to stdout, so redirecting output to a file (as in the example here) is your quickest way to saving your new key.