I am on Debian 13 Desktop with GnuPG 2.4.7. I use a primary master key for certifying, an encryption subkey, a signing subkey, and an authentication subkey. The authentication subkey is the one SSH uses.
Here is the setup that stuck.
1. Identify the authentication subkey
gpg -K --with-keygrip
Look for the line marked [A] (Authentication) and note its keygrip, a long hexadecimal string.
2. Mark the authentication subkey for SSH
gpg-connect-agent 'keyattr <YOUR_AUTH_KEYGRIP> Use-for-ssh: true' /bye
3. Enable SSH support in the GPG agent
echo "enable-ssh-support" >> ~/.gnupg/gpg-agent.conf
4. Point SSH at the GPG agent
Add this to your ~/.zshrc:
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
This tells SSH to use the GPG agent instead of the regular SSH agent.
5. Reload the shell
source ~/.zshrc
6. Get the public key
ssh-add -L
This should print the SSH public key. If it does not, restart the agent:
gpgconf --kill gpg-agent
gpgconf --launch gpg-agent
7. Add the key to GitHub
Go to GitHub, then Settings → SSH and GPG keys → New SSH key. Paste the public key, give it a descriptive title, and save.
8. Test the connection
ssh -T git@github.com
You should see GitHub’s success message.
The part that mattered for me was the keygrip. Without marking the authentication subkey explicitly, the agent has no reason to offer it to SSH. Once that line is in place, the rest is just plumbing.
Thanks for reading.
Written by Jim Merioles / April 27, 2026