Member-only story

How to Generate SSH Keys in Linux

Generate SSH keys for setting up SSH Key Authentication

Mwiza Kumwenda
2 min readApr 2, 2020

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 “youremail@xxx.com”

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

--

--

Mwiza Kumwenda
Mwiza Kumwenda

No responses yet