- Create a SSH key
ssh-keygen -t rsa -C "[email protected]"
# this is also okay
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# maybe this (up to your preference)
ssh-keygen -t ed25519 -C "[email protected]"
- Copy the public key (.pub) to clipboard
- Paste into GitHub SSH and GPG keys page
- Verify the connectivity
ssh -T -v [email protected]
# 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> [email protected]
- 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
}
Sidenote: If you are using SSH key and works with private stuff, you need to interact with them using SSH protocol, not HTTP.
- Upload your previously-created keys (or just create a new key) to GitHub SSH and GPG keys page. Make sure to specify it as
Signing Key
. 1.1. Optional
- Run this command to always verify your commit in a specific local repo:
git config commit.gpgsign true
- Run this command to always verify your commit:
git config --global commit.gpgsign true
- Let Git know about your signing key
git config --global gpg.format ssh
git config --global user.signingkey /PATH/TO/.SSH/KEY.PUB
- Verify by signing a commit
git commit -S -m "<example>"