Creating an SSH Key Pair with ssh-keygen

Here’s how to setup an SSH Key Pair for convenient usage such as easy authorization with GitLab or GitHub.

But First …

Step by Step

Enter the ssh-keygen command and accept all the defaults by hitting Enter on everything.

Generating public/private rsa key pair.
Enter file in which to save the key (/home/rwx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/rwx/.ssh/id_rsa.
Your public key has been saved in /home/rwx/.ssh/
The key fingerprint is:
SHA256:py0qcFZLPV3OtXMlDdjWPco44nGf6v4WR4wesOJEyoU rwx@sk
The key's randomart image is:
+---[RSA 2048]----+
|        .    o.+.|
|       E o .o =.=|
|      ..+. +=o+oo|
|      ooo=.=o=oo.|
|     o .S.* + +o |
|  . o .  *   = . |
|   +    o . . o  |
|    .  . . . .   |
|     ..   ooo.   |

Now you have a public and private key in your ~/.ssh/ directory.

cat ~/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSLgcGIz6b88L6PMRRjEXnUpopCeLxE3C8+gHGvAQbiZER0OT3q5HnRa7vkZf4HiP0v0OvVO+V73ogeBTc9Q7/wy578wO1sXVzkW6782pqwGCibjopFOBxN1jGa2o6He1S7t+DvRZGXsiHJ8moRTUsX1DHMJZN4bflmAF2oL29/78dezVN8mf4rfGdz3HiaWLnETR1Xn9LY+CRQpvYyP8tYunmPsxSdibX3v5o9CBx2hL4inElhnEUia308jQ1S5Vh5+cKsTK1Md0H4UPX7nmz9Fn1ff+ETzm0FcBWzj1RqA3wThbkqqPY5NsD/TnpZT2+4On70mSqZn0CSn1z0aOD rwx@sk

At this point you may want to cut and paste your public key into a service like GitLab.

[Adding a Public Key to GitLab Settings]