-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote-gpg
More file actions
executable file
·28 lines (24 loc) · 795 Bytes
/
Copy pathremote-gpg
File metadata and controls
executable file
·28 lines (24 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
# remote-gpg - Run gpg operations on a remote host
#
# original author: Dustin J. Mitchell <dustin@cs.uchicago.edu>
set -e
if [ $# -lt 1 ] ; then
echo "Supply a hostname"
exit 1
fi
host="$1"
# our local and remote homedirs might be different
# TODO remote homedirs can vary in paths, too
REMOTE_HOME=/home/deploy
LOCAL_HOME=/home/vagrant
# remove any existing agent socket (in theory `StreamLocalBindUnlink yes`
# does this, but in practice, not so much)
ssh $host /bin/sh -c 'set -u; rm -f $HOME/.gnupg/S.gpg-agent'
ssh \
-t -R "$REMOTE_HOME/.gnupg/S.gpg-agent:$LOCAL_HOME/.gnupg/S.gpg-agent-extra" \
$host \
sh -c "echo; echo \"Perform remote GPG operations and hit enter\"; \
read; \
sleep 1; \
rm -f $REMOTE_HOME/.gnupg/S.gpg-agent";