Generate SSH Keys Online

Rakesh Samal
1 min readMay 6, 2020

--

ssh-keygen authentication key generation, management, and conversion

Generate an RSA SSH key pair with a 4096-bit private key

ssh-keygen -t rsa -b 4096 -C "RSA 4096 bit Keys"

Generate a DSA SSH keypair with a 2048 bit private key

ssh-keygen -t dsa -b 1024 -C "DSA 1024 bit Keys"

Generate an ECDSA SSH keypair with a 521-bit private key

ssh-keygen -t ecdsa -b 521 -C "ECDSA 521 bit Keys"

Generate an ed25519 SSH keypair- this is a new algorithm added in OpenSSH.

ssh-keygen -t ed25519

Extracting the public key from an RSA keypair

openssl rsa -pubout -in private_key.pem -out public_key.pem

Extracting the public key from a DSA keypair

openssl dsa -pubout -in private_key.pem -out public_key.pem

Copy the public key to the server
The ssh-copy-id command
ssh-copy-id user@hostname copies the public key of your default identity (use -i identity_file for other identities) to the remote host

SSH Running on a different port

ssh-copy-id -i "user@hostname -p2222"

-i switch defaults to ~/.ssh/id_rsa.pub, if you want another key, put the path of the key after

Converting keys between OpenSSL and OpenSSH

  • Extract Public key from the certificate

openssl x509 -in cert.pem -noout -pubkey >pubkey.pem cat pubkey.pem

  • Use the following command to convert it to authorized_keys entry
$ ssh-keygen -i -m PKCS8 -f pubkey.pem

--

--