Skip to content

Instantly share code, notes, and snippets.

@stemid
Created October 4, 2015 19:56
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 stemid/1ae5544dc3fc242842e0 to your computer and use it in GitHub Desktop.
Save stemid/1ae5544dc3fc242842e0 to your computer and use it in GitHub Desktop.
#!/bin/bash
GPGVERS=$(gpg2 --version |grep gpg|awk '{print $3}'|cut -d"." -f2 )
if [ $GPGVERS -ge 1 ]; then
gpg-connect-agent /bye
export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh
export GPG_AGENT_INFO=$HOME/.gnupg/S.gpg-agent
else
# Copyright (c) 2010 Diego E. Pettenò <flameeyes@gmail.com>
# Available under CC-BY license (Attribution)
if ! [ -f "${HOME}/.gpg-agent-info" ] ||
! pgrep -u ${USER} gpg-agent >/dev/null; then
gpg-agent --daemon --enable-ssh-support --scdaemon-program /usr/libexec/scdaemon --log-file ~/.gnupg/gpg-agent.log
fi
# for ssh-agent forwarding, override gnome-keyring though!
if [ -n ${SSH_AUTH_SOCK} ] && \
[ ${SSH_AUTH_SOCK#/tmp/keyring-} = ${SSH_AUTH_SOCK} ]; then
fwd_SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
fi
export SSH_AUTH_SOCK
if [ "${fwd_SSH_AUTH_SOCK}" != "" ]; then
SSH_AUTH_SOCK=${fwd_SSH_AUTH_SOCK}
export SSH_AUTH_SOCK
fi
source ${HOME}/.gpg-agent-info
export GPG_AGENT_INFO
export SSH_AGENT_PID
GPG_TTY=$(tty)
export GPG_TTY
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment