Skip to content

Instantly share code, notes, and snippets.

@codemedic
Forked from landro/gpg.md
Last active August 31, 2022 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemedic/2687895ec5ab070ae68c49ca0e0859f3 to your computer and use it in GitHub Desktop.
Save codemedic/2687895ec5ab070ae68c49ca0e0859f3 to your computer and use it in GitHub Desktop.
Configure ssh-agent emulation in gpg-agent

Install gnupg

brew install gnupg
brew install pinentry-mac

Make sure you have gpg 2.1.20 or better

gpg --version
gpg (GnuPG) 2.1.20
libgcrypt 1.7.6
Copyright (C) 2017 Free Software Foundation, Inc.

.bashrc or similar

gpgconf --launch gpg-agent
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)

.gnupg/gpg-agent.conf

enable-ssh-support
pinentry-program /usr/local/bin/pinentry-mac

Find keygrip of your authentication key (A)

gpg --list-secret-keys --with-keygrip
--------------------------------------
sec   rsa4096 2015-11-16 [SC]
      02064FE662CC40719EE8B5D287773A4099242559
      Keygrip = B5A9ABC2111E2BC82F4CC3F98EB83498B54C8A27
uid           [ultimate] Stefan Magnus Landrø <stefan.landro@gmail.com>
uid           [ultimate] Stefan Magnus Landrø <stefan.landro@bekk.no>
ssb   rsa4096 2015-11-16 [E]
      Keygrip = 97709BC2DA4F62F886642B7CC0962C0C16C928BB
ssb   rsa4096 2017-03-29 [A]
      Keygrip = 0B070A3598334830226FE91B930ABA325624CFF1

Add keygrip of authentication key to sshcontrol .gnupg/sshcontrol

Remember newline at end of file!

Export ssh key from gpg

gpg --export-ssh-key 02064FE662CC40719EE8B5D287773A4099242559
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment