git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/bin/ssh-with-gpg
blob: 7ca0d67c36f4b2687e1771d9b8997974e876cfba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/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
fi

TGT="$1"

REMUID="$(ssh "$TGT" "id -u")"
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.gpg-agent":"/run/user/$(id -u)/gnupg/S.gpg-agent-extra" -o "StreamLocalBindUnlink=yes" "$TGT" "${@:2}"
td> * less variable spamH. P. 2022-03-231-23/+25 * remove old dirmngr socket. remember to execute only once with multiple connec...H. P. 2022-03-231-0/+1 * include gnupg in tarballH. P. 2022-03-231-1/+1 * $SSH_AUTH_SOCK only on the admin stationsH. P. 2022-03-231-2/+10 * enable ssh-support in gpg-agentH. P. 2022-03-231-0/+1 * wrong order :-)H. P. 2022-03-231-5/+1 * TGT was missing, lel. Also: passing remaining arguments now.H. P. 2022-03-231-1/+1 * alias for ssh-with-gpgH. P. 2022-03-231-0/+1 * untested behaviour: ssh-with-gpgH. P. 2022-03-231-0/+20 * $meaningful_git_commit_message[213]H. P. 2022-03-232-0/+5 * +gnupgH. P. 2022-03-234-0/+24 * launch dirmngrH. P. 2022-03-231-1/+1 * adding gpg-connect-agent to ssh agent machinesH. P. 2022-03-231-0/+1 * + syntastic