Yubikey

SSH TO SERVER ON LINUX

# 1. Install requirements (if not already present)
sudo apt install gnupg2 scdaemon pcscd
 
# 2. Start the smartcard daemon
sudo systemctl start pcscd
 
# 3. Import your public key 
gpg --card-edit
> fetch
 
# 4. Verify the card is detected
gpg --card-status
 
# 5. Set up SSH agent (same as above)
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --kill gpg-agent
gpgconf --launch gpg-agent
 
# 6. Verify SSH sees the key
ssh-add -L
# Should show your key
 
# 7. SSH to your server
ssh user@your-server

Git Commit Signing with YubiKey

# Set your signing key
git config --global user.signingkey YOUR_KEY_ID
 
# Use GPG for signing
git config --global gpg.program gpg
 
# Sign all commits by default
git config --global commit.gpgsign true
 
# Sign all tags by default
git config --global tag.gpgsign true