Skip to content

Instantly share code, notes, and snippets.

@naftulikay
Created September 2, 2015 22:39
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 naftulikay/1b8d480e8d2b8db64ccc to your computer and use it in GitHub Desktop.
Save naftulikay/1b8d480e8d2b8db64ccc to your computer and use it in GitHub Desktop.
GPG agent with SSH support and remote passthrough.
#!/bin/bash
# ... normal .bashrc stuff
# if our gpg agent environment file exists _and_ we're not over SSH
if [[ -f "$HOME/.gpg-agent-info" && -z "$SSH_CLIENT" ]]; then
# load environment variables to use local gpg agent for gpg and SSH
source "$HOME/.gpg-agent-info"
export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID
fi
# set gpg's tty to the current tty
export GPG_TTY="$(tty)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment