How-to, notes, thoughts


Add new SSH key for GitHub on MacOS

To add new SSH key for GitHub on MacOS, follow these steps:

  1. Generate a new SSH key:

ssh-keygen -t rsa -b 4096

  1. Create ssh/.config file:

touch ~/.ssh/config

andd add the following content:

Host github.com
        User git
        Hostname github.com
        PreferredAuthentications publickey
        IdentityFile /home/user/.ssh/id_rsa
  1. Add the new SSH key to the SSH agent:

ssh-add ~/.ssh/id_rsa

  1. Copy the SSH key to the clipboard:

pbcopy < ~/.ssh/id_rsa.pub

  1. Log in to GitHub and go to Settings -> SSH and GPG keys -> New SSH key and paste the SSH key.

You’re ready to use the git clone command.