dotfiles/files/.bash_sshagent

20 lines
490 B
Bash
Raw Normal View History

2016-09-04 13:58:13 +02:00
#!/bin/bash
2016-12-13 16:06:25 +01:00
if ! which gpg-connect-agent > /dev/null 2>&1; then
# GPG-agent is not installed on this machine, don't do anything.
return
fi
2016-09-04 15:07:40 +02:00
mkdir -p ~/.gnupg
2016-09-04 13:58:13 +02:00
# Start the gpg-agent if not already running
if ! pgrep -x -u "${USER}" gpg-agent >/dev/null 2>&1; then
gpg-connect-agent /bye >/dev/null 2>&1
fi
# Set SSH to use gpg-agent
unset SSH_AGENT_PID
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null