Create an SSH Key Pair on macOS and Linux

SSH keys are important in different authentication mechanisms. Developers mostly use them for git authentication to a remote repository.

With ssh-keygen it is possible to create a so called key pair. One is the private key, which stays untouched on your disk, and the other one is the public key. The second one is the one you need to store on the server you want to authenticate yourself. This could be a site like GitHub for example.

ssh-keygen creates a key pair.

cat ~/.ssh/id_rsa.pub can be used to view the public key directly in the terminal. Of course you can open this file with any other editor. If any website demands a public SSH key, the contents of this file is what you need to copy paste.