SSH keygen

$ ssh-keygen -t rsa -b 4096 -C "[[email protected]](/cdn-cgi/l/email-protection)" 

- - -
-t Type of key
-b The number of bits in the key
-C Provides a new comment
Generate an RSA 4096 bit key with email as a comment

Key format

  • PEM
  • PKCS8

known_hosts

Search from known_hosts

$ ssh-keygen -F <ip/hostname>

Remove from known_hosts

$ ssh-keygen -R <ip/hostname>

Key type

  • rsa
  • ed25519
  • dsa
  • ecdsa

Generate

Generate a key interactively

$ ssh-keygen

Specify filename

$ ssh-keygen -f ~/.ssh/filename

Generate public key from private key

$ ssh-keygen -y -f private.key > public.pub

Change comment

$ ssh-keygen -c -f ~/.ssh/id\_rsa

Change private key passphrase

$ ssh-keygen -p -f ~/.ssh/id\_rsa
Comments