SSH Keygen

To create a private and public key pair run the command ssh-keygen

Syntax :

ssh-keygen 
-t <dsa|rsa|ecdsa|ed25519> //Specifies the type of key to create.
-b 2048 //Number of bits
-v Verbose
-N 'passphrase'

Examle : ssh-keygen -t rsa -b 202 -N 'xxxxx' -f '/home/temp/sftp_rsa'

But you can also run the command ssh-keygen and let the prompt help you example below :

The keys are created at location ~/.ssh

id_rsa is the private key
id_rsa.pub is the public key

Contents of id_rsa private key

Contents of id_rsa.pub i.e the content of the public key

Check the fingerprint/algorithm/bits of a public key (A hash of a public key)

//l for listing
//v for verbose
//-E for hasing algorithm

ssh-keygen -lv -E <md5|SHA256> -f id_rsa.pub
ssh-keygen -lv -E SH256 -f id_rsa.pub

2048 SHA256:pcnZLDwdET9rvXM9S9CGaed1pvOxGUGOW3i+kH6OzcE tyson@tyson-Lenovo-ideapad-330-15IKB (RSA)

Verify the passphrase of a private key

ssh-keygen -y -f '/home/tyson/Desktop/Test/temp/sftp_rsa'

You can copy your SSH public key to a remote machine using below command

ssh-copy-id username@remote-ip
ssh-copy-ip sfpt@10.192.168.0.1

Certificates :

Read Me :

SSH-Keygen manual
https://man.openbsd.org/ssh-keygen


Some information on certificates
https://serverfault.com/questions/9708/what-is-a-pem-file-and-how-does-it-differ-from-other-openssl-generated-key-file

Leave a Comment