From ed38fa7e33af9162974e940e797d4eb1f11e3d42 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Thu, 24 Mar 2022 09:25:00 +0100 Subject: gnupg forwarding now working --- .bash/exec.bash | 1 + .gnupg/gpg-agent.conf | 1 + bin/ssh-with-gpg | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.bash/exec.bash b/.bash/exec.bash index 316d1c4..a469ccf 100644 --- a/.bash/exec.bash +++ b/.bash/exec.bash @@ -13,6 +13,7 @@ if echo "${SSHAGH[@]}" | grep -F --word-regexp "$(hostname -f)" > /dev/null;then "$HOME/bin/ssh-agent-launcher" -q if ! ps -fp "$(pgrep -d, -x dirmngr)" | grep "^$(whoami)" > /dev/null gpg-connect-agent --dirmngr /bye 2>/dev/null + gpg --list-secret-keys >/dev/null 2>&1 fi fi fi diff --git a/.gnupg/gpg-agent.conf b/.gnupg/gpg-agent.conf index 18f2e87..1758bd0 100644 --- a/.gnupg/gpg-agent.conf +++ b/.gnupg/gpg-agent.conf @@ -7,3 +7,4 @@ disable-scdaemon #max-cache-ttl 900 #default-cache-ttl 900 enable-ssh-support +extra-socket /run/user/21337/gnupg/S.gpg-agent-extra diff --git a/bin/ssh-with-gpg b/bin/ssh-with-gpg index aac1651..7ca0d67 100755 --- a/bin/ssh-with-gpg +++ b/bin/ssh-with-gpg @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# For this to work, you also need to import the public key of any private key you want to use +# in the target server's pubring first. + if [ -z "$1" ];then printf "USAGE: %b TARGET [OPTIONS...]\\n" "$(basename "$0")" >&2 exit 1 @@ -8,10 +11,10 @@ fi TGT="$1" REMUID="$(ssh "$TGT" "id -u")" -ssh "$TGT" 'rm -f /run/user/$(id -u)/gnupg/S.dirmngr' +ssh "$TGT" 'killall gpg-agent 2>/dev/null;rm -f /run/user/$(id -u)/gnupg/S.*' if [ -z "$REMUID" ];then printf "Cannot fetch user id from %b.\\n" "$TGT" >&2 exit 2 fi -ssh -R "/run/user/${REMUID}/gnupg/S.dirmngr":"/run/user/$(id -u)/gnupg/S.dirmngr" -o "StreamLocalBindUnlink=yes" "$TGT" "${@:2}" +ssh -R "/run/user/${REMUID}/gnupg/S.gpg-agent":"/run/user/$(id -u)/gnupg/S.gpg-agent-extra" -o "StreamLocalBindUnlink=yes" "$TGT" "${@:2}" -- cgit v1.2.3