- Create a SSH key
ssh-keygen -t rsa -C "your_email@example.com"
# this is also okay
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# maybe this (up to your preference)
ssh-keygen -t ed25519 -C "your_email@example.com"
- Copy the key to clipboard
- Paste into GitHub SSH and GPG keys page
- Verify the connectivity
ssh -T -v git@github.com
# or this if you use custom key name (instead of the normal id_rsa)
# more information: https://serverfault.com/questions/1119891/ssh-not-working-when-custom-key-name-is-used
ssh -T -v -i <custom_file_name> git@github.com
- By default, for some reason, new session of Bash/ZSH may not load your SSH key, therefore, you need to initialize a SSH agent and load your key each time you start a new session.
ssh-add &>/dev/null || eval `ssh-agent` &>/dev/null
[ $? -eq 0 ] && {
ssh-add ~/.ssh/<your_key_name> &>/dev/null
}