Add new SSH key for GitHub on MacOS
To add new SSH key for GitHub on MacOS, follow these steps:
- Generate a new SSH key:
ssh-keygen -t rsa -b 4096
- 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
- Add the new SSH key to the SSH agent:
ssh-add ~/.ssh/id_rsa
- Copy the SSH key to the clipboard:
pbcopy < ~/.ssh/id_rsa.pub
- 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.