Creating SSH Keys

Creating SSH Keys on a Mac

1. Create Key Pair

ssh-keygen

This will create an OPENSSH key pair

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/Base/.ssh/id_rsa): ssh-key-1

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in ssh-key-1.

Your public key has been saved in ssh-key-1.pub.

The key fingerprint is:

SHA256:bmp/OfTsaizGbGB8WXC0dwNyWtn/k+vb4s0KFVQzpQk Base@Base Laptop

The key's randomart image is:

+---[RSA 2048]----+

|         .o Eo.++|

|        . .*.+.oo|

|         oo . *. |

|          .. . o.|

|     .  So    . o|

|      +.o .  . o.|

|     . =oo +.   o|

|      .o* * o..+.|

|     ..+.+.+..+==|

+----[SHA256]-----+

 

2. Convert Private Key to RSA format

ssh-keygen -p -m PEM -f ssh-key-1

This will convert the Private Key to RSA format

Base Laptop: ssh Base$ ssh-keygen -p -m PEM -f ssh-key-1

Enter old passphrase: 

Key has comment 'Base@Base Laptop'

Enter new passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved with the new passphrase.

RESULT:

-----BEGIN RSA PRIVATE KEY-----

Proc-Type: 4,ENCRYPTED

DEK-Info: AES-128-CBC,5E5005DB0F2F88AF471AE1D4AFB18207

KTkhUUJ/9hAl+yexoFUFRW0uuO3lyy9fdsQpTBAP5KypgWGoKwoTyroaCX9dBDst

g3qsmDl1qYHhQtZ2ozZg8G4LGmsrzcXn2il0nFSdybbhRJ1suASX2G8CUo4qPsw6

XTdPzNDMlK7dyVUkY2fiwbumzd/TiHBR/Ey6GkAQC+H5vymYqcg5jiqFh9ZF90ru

bv6NYZ8Q8pg5UR6TWJLPYx5A82HuSxDE/vPyXS32uPhuPk28HZMSQz5YhJYD024+

1DlWWpwhq110yek+1+IbSipY03HQH5orEP3LGVbTMWpFknSY3mwvaSb6pfCEBm7X

vWi8xjMCGmklq7/11ia8iXmcvE0zeaGCiIiT2XNpwlBnftPvf7SytWAqj+qSX0E4

xvwi1bMK7SDFJ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GKntjOzZWP0uUHm

pXRPuKXS/sEgknbZim+Z0eUiBv4SZH14HodWhkXGSfNH5ZCvzy3OXTaHw37qVLCt

m4kQFvzmgwY3xMAIRDzjtkrQcZ3vNJliVEmX4PVDtq2i6s271OjUVSUy5Vl0n9Rw

-----END RSA PRIVATE KEY-----

 

Creating SSH Keys on Windows

1. Download and install Git from https://git-scm.com/download/win (Install with all of the default settings, i.e. click Next all the way through with the default options)

2. In Windows, press Start+R to launch the Run dialog.

3. Type C:\Program Files\Git\bin\bash.exe and press Enter. (This will open the Git Bash shell where you will run the remainder of the commands)

4. At the Git Bash command line, change into your preferred directory and type: mkdir .ssh

5. To create the key pair, then run: ssh-keygen.exe

6. When prompted for a password, type a password to complete the process. When finished, the output looks similar to:

sh-keygen.exe

Generating public/private rsa key pair.

Enter file in which to save the key (/c/Users/win-key-test/.ssh/id_rsa): /c/Users/win-key-test/.ssh/

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /c/Users/win-key-test/.ssh/

Your public key has been saved in /c/Users/win-key-test/.ssh/

The key fingerprint is:

SHA256:jieniOIn20935n0awtn04n002HqEIOnTIOnevHzaI5nak test@keytest

The key's random art image is:

 

 +---[RSA 2048]----+

 |*= =+.           |

 |O*=.B            |

 |+*o* +           |

 |o +o.  .         |

 | ooo  + S        |

 | .o.ooo* o       |

 |  .+o+*oo .      |

 |   .=+..         |

 |   Eo            |

 +----[SHA256]-----+

 

$ dir .ssh

id_rsa  id_rsa.pub   

7. You will then need to convert the key to a PEM format by running the following command: ssh-keygen -p -m PEM -f win-key-test