From 7f43c0bf1961adacb2b9e4b496e148919e20fad5 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 3 Apr 2018 11:27:43 +0200 Subject: gpg: fixed agent misconnection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a fix for a weird error that just happened to me. Signed-off-by: Miquel Sabaté Solà --- bashrc | 23 +++++++++++++++++++++++ gnupg/gpg-agent.conf | 2 ++ 2 files changed, 25 insertions(+) diff --git a/bashrc b/bashrc index dbcf965..1bbdd4c 100644 --- a/bashrc +++ b/bashrc @@ -122,3 +122,26 @@ export NODE_VERSION="8" # Finally RVM requires it to be the last thing on the PATH for whatever reason. [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" export PATH="$PATH:$HOME/.rvm/bin" + +## +# Lastly I had some problems with the GPG agent recently. So I copied a solution +# from https://github.com/jessfraz/dotfiles + +# Use a tty for gpg +GPG_TTY=$(tty) +export GPG_TTY + +# 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 + gpg-connect-agent updatestartuptty /bye >/dev/null +fi + +# Set SSH to use gpg-agent +unset SSH_AGENT_PID +if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then + export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh" +fi + +# Add alias for ssh to update the tty +alias ssh="gpg-connect-agent updatestartuptty /bye >/dev/null; ssh" \ No newline at end of file diff --git a/gnupg/gpg-agent.conf b/gnupg/gpg-agent.conf index 5272bca..67c7dae 100644 --- a/gnupg/gpg-agent.conf +++ b/gnupg/gpg-agent.conf @@ -1,3 +1,5 @@ pinentry-program /usr/bin/pinentry-qt4 max-cache-ttl 720000 default-cache-ttl 720000 +enable-ssh-support +use-standard-socket \ No newline at end of file -- cgit v1.2.3