Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aminmiri/e77eb72ae8697e95040bf5d50b1e6f65 to your computer and use it in GitHub Desktop.
Save aminmiri/e77eb72ae8697e95040bf5d50b1e6f65 to your computer and use it in GitHub Desktop.
Protect SSH access to your repositories using a security key
# CHNAGE PATH ACCORDING TO YOUR WORKING ENVIRONMENT
# Generate the SSH Key
ssh-keygen -t ed25519-sk -O resident -C "yubico_key_0" -f ~/.ssh/yubico_key_0
vi ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/yubico_key_0
IdentitiesOnly yes
# add public ssh key to github for signing AND authentication
cat ~/.ssh/yubico_key_0.pub
# configure your Git client to use the SSH key format instead of the default PGP key format
git config --global gpg.format ssh
# instruct Git to use the generated key for signing
git config --global user.signingKey ~/.ssh/yubico_key_0
# you may need to create this file
touch /home/miri/.ssh/allowed_signers
# testing the connection
ssh -T [email protected]
# test clone
git clone [email protected]:aminmiri/demo.git
# git log can show and verify signatures:
git log --oneline --show-signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment