How to generate ssh rsa key from command line

This tutorial explains how to generate ssh rsa key from command line.

Below command is used to generate rsa key pair.

ssh-keygen -t rsa

The following is an example used for generating ssh rsa key and a passphrase.

[k@sysadminforest ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/k/.ssh/id_rsa): 
Created directory '/home/k/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/k/.ssh/id_rsa.
Your public key has been saved in /home/k/.ssh/
The key fingerprint is:
The key's randomart image is:
+---[RSA 2048]----+
|   .+.+o     .   |
|   . o.oo   o o  |
|  . .... .   = . |
| o .  +.  . . o +|
|. . ooE.S...   +.|
|   . ...oo    . o|
|      +o.+     = |
|     .o+=.oo  o .|
|    ...o.==oo. .o|

Once you type the command and hit ENTER, it prompts for location to save the key file.

By default, it picks the HOMEDIR/.ssh path, however you can change the path to save the file.

Passphrase is used to increase security for key based authentication. Be sure to choose a strong passphrase.

It is possible to use key based authentication without passphrase. If you want to do that, just hit enter without adding any passphrase.

You can generate an RSA key from command line usingĀ thisĀ link.

Add a Comment

Your email address will not be published. Required fields are marked *