How to generate SSH private/public key pair on Ubuntu 16.04

Profile picture for user devraj

SSH public key can be of different bit but to work on Acquia Cloud you require SSH key of 4096 bites.

Below is the method to generate SSH private/public key pair using the ssh-keygen command.

Step 1: Open Terminal and Run this commands to check you do not have public key saved on your system.

$ cd ~/.ssh
$ ls -l

if the directory or file already exist, run following command to take backup and avoid overwrite

$ mkdir key_backup
$ mv id_rsa* key_backup

Step 2: Use Keygen command to generate new public/private key pair

ssh-keygen -b 4096

It will ask for several question. Like filename and passphrase. For filename Press enter to use default name and location and for passphrase you can enter your name or any string you remember. Check below output on my system. 

Generating public/private rsa key pair.
Enter file in which to save the key (/home/userName/.ssh/id_rsa): 
Created directory '/home/userName/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/userName/.ssh/id_rsa.
Your public key has been saved in /home/userName/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:mj3gV04u69TUcWpaBfH+g/+akLR1Pm+BCGv0iAGO2sY userName@userName-Lenovo
The key's randomart image is:
+---[RSA 4096]----+
|            o.   |
|     .       o   |
|    o .     . +  |
|   . . . o . *   |
|  +   . S O B + .|
| . E . * @ B =.= |
|  .   + B = +. o+|
|       o +   ...=|
|       .o     o++|
+----[SHA256]-----+