How to Generate SSH Keys in Linux
In this guide, I will show you how to generate a private/public ssh key pair using Linux Ubuntu. SSH keys offer a very robust and more secure alternative to password based login.
Most Linux distros come with a built-in ssh key generator (ssh-keygen) that you can access from the command line.
Generate Public/Private SSH Key Pair
Open the command terminal. You can use the shortcut
Crtl + Alt + T.
In the command prompt, use the ssh-keygen command and supply your email address as follows:
ssh-keygen -C “firstname.lastname@example.org”
When prompted for file to save your key in, you can add a directory path or leave the default.
In this example, I use the following file
/home/mwiza/.ssh/id_rsa. Where id_rsa is the file in which the private key is saved. Where mwiza my username on my system.
When done. Your output will be similar to the one below.
In addition, to the id_rsa private key file another file named id_rsa.pub will be generated.
Open public key
Now head over to the directory in which the key pair file was generated. Open the id_rsa.pub file with a text editor of your choice.
Copy all content of the id_rsa.pub file as it appears below and paste into the interface provided by your remote server client.
ssh-rsa AAAAB3NzaC1ycfsgsfgsgsksgAQABAAABAQDfHEiJHGit1HB04b/H8TPLMxMtFtTXsPN+f3pg3/DJFKDFJDFDFDFDFDFFdfgfgfgfsgH/k+fgAOzAVI9n9UR5R3FDxVXsJOv6ASMtbto3bjbjwFj0bwunUWFO/0uKvBsjftUzj5mwL8emrk7rShN5zSQBvzAqRCCVXd0e+KNZSZO00KwAgexQJhsKyqummIa+5fcXk4Jzn5geerleGZk3iNaI4ztJdxQLgMrNrG6rEQRqM0StzcXMnfdfdwUj2CFwO0sdfafafafgsgskHHHSHHDSHDSHDHSDHDS+uBej4Ok/VGaDuV email@example.com
In the picture below is an example interface to accept a public key, from Azure DevOps.
That’s it. it’s very easy to generate SSH keys using the
ssh-keygen command. Newer versions of windows also come with a built-in
ssh-keygen command tool, which is a nice alternative to generating SSH keys via putty.