Creating a Public Key from a Private Key in SSH

2 min read
SecuritySSHDevOps

Recently, I needed to find the corresponding public key from a private key (.pem) to give a Linux user access to a server. Below are the commands I used to generate the public key.

SSH Method

bashcode
ssh-keygen -y -f privatekey > publickey

OpenSSL Alternative

This code generates an OpenSSL key, which wasn't what I needed in that specific case, but might also come in handy.

bashcode
openssl rsa -in privatekey -pubout > publickey