Open Terminal and type:
$ ssh-keygen -t rsa -b 4096 -C "yourname@yourdomain.com"
Use the defaults by pressing enter.. Generic Example:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/john.doe/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/john.doe/.ssh/id_rsa.
Your public key has been saved in /Users/john.doe/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:s/NA0e62g1zjEmAtUIi42/cEEicAGVs+fDcuAtOFlrY john.doe@doeinc.com
The key's randomart image is:
+---[RSA 4096]----+
| .o+o+oo.|
| o+o.+oo.=|
| . o+.+=+++|
| o o++++.|
| .S. ..*o.o|
| o=o.o+.. |
| o.o.+E* |
| ++.++ o |
| .++.. +|
+----[SHA256]-----+
Change to .ssh directory
$ cd ~/.ssh/id_rsa
Open the public key
$ nano ~/.ssh/id_rsa.pub
Copy all the text
Open Github.com
Go to Settings (Upper right avatar icon)
Choose SSH and GPG Keys
Click "New SSH Key"
Paste your key into the text area and give it a name.
Click "Save"