GitHub SSH key setup (macOS) - renekuda38/git GitHub Wiki

This guide is mainly for my personal usage. But feel free to use it.

Check the official guides.


1. Check existing SSH keys in your home directory

  • ls -al ~/.ssh

2. Generate SSH keys

3. Add SSH key to the ssh-agent

3.1 Start ssh-agent in the background

  • eval "$(ssh-agent -s)"

3.2. Modify ~/.ssh/config file

touch ~/.ssh/config # if it's not created already

# put below text into that file:
Host github.com
  AddKeysToAgent yes
  UseKeychain yes # if you used passphrase for your key
  IdentityFile ~/.ssh/id_ed25519 # name based on your file

3.3 Add your SSH private key to the ssh-agent and store your passphrase in the keychain

  • ssh-add --apple-use-keychain ~/.ssh/id_ed25519
  • --apple-use-keychain = -K

4. Add SSH key to your GitHub account

$ pbcopy < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard
  • then paste the key to GitHub SSH settings

5. Now connect to GitHub repo via SSH

⚠️ **GitHub.com Fallback** ⚠️