Created
October 4, 2015 19:56
-
-
Save stemid/1ae5544dc3fc242842e0 to your computer and use it in GitHub Desktop.
Pasted for this guide http://wiki.sydit.se/teknik:guider:smartkort_med_ssh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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ò <[email protected]> | |
# 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