Setup GitHub on Mac OS X

Installing and setting up GitHub is well documented but I wanted to create a quick concise guide for myself to save time digging through bookmarks and Googling everything again. Hopefully others may find this guide useful as well.

Install GitHub

The first step is to install Home Brew on Mac OS X.

Install Homebrew by opening a terminal window and typing the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Home Brew is installed we can easily install GitHub with the following command:

brew install git

Setup an SSH Key Linking Your Computer to GitHub

Setting up an SSH key for authentication avoids having to continually login via  HTTPS, I used the GitHub user guide which can be found here, a summary of the steps are included below.

Open a new terminal and type the following command in using the same email address used with your GitHub account

ssh-keygen -t ed25519 -C "[email protected]"

Press Enter when prompted to “Enter a file in which to save the key” the default location used is /Users/you/.ssh/

Add a password when prompted “Enter passphrase (empty for no passphrase):” this will assign a passphrase to your SSH keys securing them in the event someone gains access to your computer, if you aren’t worried about that, you can just press enter and leave this field blank. There is an option to add this password to your OS X keychain, more information can be found here.

Next, we will need to setup the SSH config file to automatically load the SSH key, check to see if the /.ssh/config file exists.

open ~/.ssh/config

You may see the following message if the file doesn’t exist:

The file /Users/you/.ssh/config does not exist.

To create an SSH config file type the following command:

touch ~/.ssh/config

Type open ~/.ssh/config again to open the config file and enter the following replacing id_ed25519 with the name of the SSH key you generated in the previous steps.

If you didn’t enter a password in step 3 you should delete UseKeychain yes.

Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519

Start the ssh-agent:

eval "$(ssh-agent -s)"

Next we need to add the SSH key to the OS X ssh-agent use the following again replacing id_ed22519 with the name of the key generated in step 1.

ssh-add -K ~/.ssh/id_ed25519

Next we need to copy the public key and add it to your GitHub Account, to accomplish this enter the following command replacing id_ed25519 with your key name.

pbcopy < ~/.ssh/id_ed25519.pub

Login to your GitHub account, in the top right-hand corner click your profile photo and select Settings then SSH and GPG keys. Click the New SSH key button, enter a description of the computer that you are setting up and paste the key into the box ensuring no additional characters or spaces are included and click Add SSH Key.