05

Lesson 5 of 12

GitHub Account & SSH Authentication

Create a GitHub account, sign in with the GitHub CLI, and set up SSH so you never have to type a password when pushing code.

~10 min·Mac
05 / 12GitHub Account & SSH Authentication

Step 1: Create a GitHub account

If you don't have one yet, go to github.com and sign up. Tips for choosing a username:

  • Lowercase with hyphens (e.g. your-name or yourname)
  • Professional — it appears in every project URL you share
  • Short — you'll type it often

Verify your email after signing up.

Your GitHub profile = your developer portfolio

Add a profile picture, your name, and a short bio. Employers often look at GitHub profiles before interviews. Your projects, commit history, and contributions are all visible here.

Step 2: Log in with the GitHub CLI

The gh CLI lets you create repos, manage pull requests, and do everything GitHub-related right from your terminal. Log in:

gh auth login

When prompted, choose:

  • GitHub.com (not Enterprise)
  • SSH (not HTTPS)
  • Login with a web browser

It will open a browser window where you click "Authorize". After that, gh is authenticated.

Check it worked:

gh auth status

Step 3: Create an SSH key

An SSH key is a pair of files — a private key (stays on your Mac, never shared) and a public key (uploaded to GitHub). GitHub uses this pair to verify it's really you.

First, check if you already have one:

ls -al ~/.ssh

If you see id_ed25519 and id_ed25519.pub, you already have a key — skip to Step 4.

If not, create one:

ssh-keygen -t ed25519 -C "you@example.com"

Press Enter to accept the default file location. Use a passphrase when asked (it adds security in case your Mac is ever lost or stolen).

Step 4: Add the key to macOS Keychain

This makes your Mac remember the passphrase so you don't have to type it every time:

eval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Create (or update) ~/.ssh/config to tell SSH to always use the keychain:

mkdir -p ~/.ssh

Open the file:

open -e ~/.ssh/config

Add these lines and save:

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

Step 5: Upload your public key to GitHub

gh ssh-key add ~/.ssh/id_ed25519.pub --type authentication --title "My Mac"

Test the connection:

ssh -T git@github.com

You should see:

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

From now on, git push and git pull will work without any password prompts.

Step 6: Organize your projects folder

Before you start cloning repos, create a clean folder structure:

mkdir -p ~/Developer/GitHub
mkdir -p ~/Developer/Personal
mkdir -p ~/Developer/Experiments

Add shortcuts to your terminal config:

cat >> ~/.zshrc << 'EOF'

# Developer folders
alias dev='cd ~/Developer'
alias ghdev='cd ~/Developer/GitHub'
alias personal='cd ~/Developer/Personal'
alias exp='cd ~/Developer/Experiments'
EOF

source ~/.zshrc

Now you can type ghdev to jump straight to your GitHub projects folder. Clean and fast.

Knowledge Check

Answer all questions to mark this lesson complete.

Q1Why use SSH instead of a password for GitHub?

Q2What does `gh auth login` do?

Git First-Time Setup
Setting Up VS Code