DEV Community

Brandon Rozek
Brandon Rozek

Posted on • Originally published at brandonrozek.com on

GPG Agent as SSH Agent

GPG Agent has the ability to act as a SSH Agent. This allows the use of Authentication keys on Smartcards to be used with SSH as well.

First we need to enable SSH support in GPG Agent,

echo "enable-ssh-support" >> ~/.gnupg/gpg-agent.conf

Enter fullscreen mode Exit fullscreen mode

Then we need to specify an environmental variable for the SSH Daemon to use GPG Agent

echo "export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)" >> ~/.bashrc

Enter fullscreen mode Exit fullscreen mode

If you want it to be active immediately, then source the bashrc,

source ~/.bashrc

Enter fullscreen mode Exit fullscreen mode

If you have a smartcard plugged in, then you should be able to see it via the GPG agent

ssh-add -l

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay