This guide sets up SSH for GitHub access and enables signed Git commits using your SSH key.
If you don't have one yet:
ssh-keygen -t ed25519 -C "[email protected]"This creates
~/.ssh/id_ed25519and~/.ssh/id_ed25519.pub.
- Copy the public key:
cat ~/.ssh/id_ed25519.pub-
Go to GitHub β Settings β SSH and GPG keys β New SSH key
-
Paste the key and save.
Start the SSH agent and add your key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Optional: Add to ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
ssh -T [email protected]You should see:
Hi username! You've successfully authenticated...
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign truemkdir -p ~/.config/gitAdd this to ~/.config/git/allowed_signers:
[email protected] ssh-ed25519 AAAAC3... (from your .pub file)
Then:
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed_signersgit commit --allow-empty -m "Test signed commit"
git log --show-signatureYou should see something like:
gpg: Good signature from "[email protected]"
GitHub will show a β Verified badge if everything is set up right.
- GitHub only verifies commits signed with keys added in your SSH settings.
ed25519keys are preferred overrsa.- You can use a separate key just for signing if you want.
That's it! You're all set with SSH auth + commit signing. π