Configure SSH to use SSH key to access Git on MacOS

MacBook Air beside green leaf

Working with Git will make it more efficient using SSH keys, since you do not have to constantly enter in your username and password or personal access token. Make sure your Git site URL is set to use the SSH URL for your repo.

  1. Open Terminal
  2. Create the .ssh directory, if you don't already have
    mkdir ~/.ssh
  3. Create and/orĀ edit the ssh config file (use your favourite editor)
    vi ~/.ssh/config
  4. Copy the config info below and paste it into the ssh config file
    Host github.com
    Hostname github.com
    User git
    IdentityFile /opt/ssh/[id_rsa]
  5. Save and exit the config file
    :x!

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.