After receiving my new Macbook, I started setting up a development environment on MacOS.
To set up Git on MacOS, I generated a new SSH key on my Mackbook and
added it to my GitHub account to enable authentication for Git operations over SSH.
1. Generating a new SSH key
I open a terminal and paste the text below to generate a new SSH key:
The -t flag sets the encryption algorithm to ed25519. It was prompted to enter a passphrase.
Replace your_email@example.com with your GitHub account email.
The -C flag adds a comment or label to identify the key, and using an email address is common.
Ed25519 is a public-key signature system and elliptic curve signing algorithm that uses EdDSA and Curve25519.
2. Adding a new SSH key to the GitHub account
To copy the public key to your clipboard, you can do the following:
If pbcopy isn't working, you can locate the hidden .ssh folder,
open the file in your favorite text editor, and copy it to your clipboard.
Paste the public key into your GitHub settings. You can do this by:
Opening GitHub and logging in
Navigating to Settings
Clicking SSH and GPG keys
Clicking New SSH key
Entering a title for the key
Pasting the key into the Key section
Clicking Add SSH Key
Entering your account password if prompted
3. Git Configuration
Install Homebrew if you don't already have it, then:
Git configuration settings with the git config command.
One of the first things you did was set up your name and email address:
Check if Git can normally connect with your GitHub account with SSH:
Now you can freely use SSH to authenticate Git operations.