Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
Switched back to SSH agent.
Browse files Browse the repository at this point in the history
Until it is possible to unlock the agent on startup (if not already
unlocked) then the prompt will trigger the pinentry program and causes
all sorts of issues.
  • Loading branch information
davidtwco committed Dec 26, 2017
1 parent 9f15898 commit 6c77ea0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 14 deletions.
32 changes: 26 additions & 6 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,39 @@ if [ -f ~/.aliases ]; then
fi
# }}}

# SSH Agent {{{
# =========
env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ;
}

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi

unset env
# }}}

# GPG Agent {{{
# =========
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
if _has gpg-agent; then
eval "$(gpgconf --launch gpg-agent)"
echo UPDATESTARTUPTTY | gpg-connect-agent
fi

# If the SSH agent is running then add any keys.
if [ "$SSH_AUTH_SOCK" ] && [ $(ssh-add -l >| /dev/null 2>&1; echo $?) = 1 ]; then
ssh-add
fi
# }}}

# Environment Variables {{{
Expand Down
6 changes: 4 additions & 2 deletions .gnupg/gpg-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ max-cache-ttl 7200
default-cache-ttl-ssh 34560000
max-cache-ttl-ssh 34560000

# Act as an SSH agent.
enable-ssh-support
# Act as an SSH agent. Disabled until I can force the
# keyring for SSH to unlock on startup - else the prompt
# triggers it.
# enable-ssh-support

# Use pinentry-curses for prompt.
pinentry-program /usr/bin/pinentry-curses
32 changes: 26 additions & 6 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,39 @@ if grep -q Microsoft /proc/version; then
fi
# }}}

# SSH Agent {{{
# =========
env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ;
}

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi

unset env
# }}}

# GPG Agent {{{
# =========
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK="$HOME/.gnupg/S.gpg-agent.ssh"
if _has gpg-agent; then
eval "$(gpgconf --launch gpg-agent)"
echo UPDATESTARTUPTTY | gpg-connect-agent 1>/dev/null
fi

# If the SSH agent is running then add any keys.
if [ "$SSH_AUTH_SOCK" ] && [ $(ssh-add -l >| /dev/null 2>&1; echo $?) = 1 ]; then
ssh-add
fi
# }}}

# Path {{{
Expand Down

0 comments on commit 6c77ea0

Please sign in to comment.