How to generate SSH key for Linux?

Assuming you are using Linux operating system on your local machine, you can generate SSH to gain access to your remote server using SSH with key based authentication enabled.

You can generate SSH key using below command :

ssh-keygen -t rsa

Above command will prompt you to enter :

Enter file in which to save the key (/root/.ssh/id_rsa): 

Enter to select the default file location.

Enter passphrase (empty for no passphrase):

Enter to keep the password as nil / blank one, i.e without any password. Repeat the same for “Enter same passphrase again:”

You will then receive message, “Your public key has been saved in /root/.ssh/id_rsa.pub”

Now you have to include above id_rsa.pub key in your server’s authorized_keys file which is located at /root/.ssh/

This will help you to gain key based access to your server.

Author: whukblog

WebhostUK.Co.UK offers Best UK web hosting since 2003