How to generate SSH Key on mac

Generating ssh keys on a mac is so easy, please see below steps to generate ssh key on a mac:

Open the terminal and type

ssh-keygen -t rsa -C ""

Enter a passphrase when it prompts and confirm again.

If you don’t want to enter the passphrase every time or dont want to remember then simply add it to key-agent. To do that use the below command

ssh-add ~/.ssh/id_rsa


Steps to generate the SSH key…

ssh-keygen -t rsa -C ""
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/Sanj/.ssh/id_rsa): 
Created directory '/Users/Sanj/.ssh'.
Enter passphrase (empty for no passphrase): ENTER PASSPHRASE
Enter same passphrase again: ENTER PASSPHRASE
Your identification has been saved in /Users/Sanj/.ssh/id_rsa.
Your public key has been saved in /Users/Sanj/.ssh/
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
|        ..o.     |
|         +. .    |
|     . ...o+     |
|    . + ooo o    |
|   . . BS...     |
|  o + . +o       |
| o E   ..        |
|o                |
|o                |
ssh-add ~/.ssh/id_rsa
Enter passphrase for /Users/Sanj/.ssh/id_rsa: ENTER PASSPHRASE
Identity added: /Users/Sanj/.ssh/id_rsa (/Users/Sanj/.ssh/id_rsa)


That’s it!