Skip to content

Instantly share code, notes, and snippets.

@ashishwadekar
Last active May 21, 2020 06:26
Show Gist options
  • Save ashishwadekar/0aaa8a46c811739f1ffacc850ef3f2d3 to your computer and use it in GitHub Desktop.
Save ashishwadekar/0aaa8a46c811739f1ffacc850ef3f2d3 to your computer and use it in GitHub Desktop.
Yubikey GPG & SSH Setup on Mac OS

Guide to setting up your existing YubiKey for GPG & SSH authentication on a Mac

1. Download and install GPG Tools Suite

https://gpgtools.org/

2. Launch GPG Keychain application & import your public key & set it's trust level to Ultimate

3. Edit the file ~/.gnupg/gpg-agent.conf & add the following lines to it

enable-ssh-support
default-cache-ttl 60
max-cache-ttl 120
pinentry-program /usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac

4. Create or edit bash_profile & add the following lines to it:

GPG_TTY=$(/usr/bin/tty)
SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
export GPG_TTY SSH_AUTH_SOCK
gpgconf --launch gpg-agent

5. Source the bash_profile by running the following command:

source ~/.bash_profile

6. Test the configuration by running the following command:

ssh-add -L

If you are able to see ssh-rsa & your key then Profit 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment