summaryrefslogtreecommitdiff
path: root/create-invitation
blob: c2a5faa6cc677cd64bc37cc686dd6ffdd8885de5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

set -e

if [ $# -ne 2 ]; then
	echo "Usage: $0 <tunnel-port> <comment>" 1>&2
	exit 1
fi

KEY=tmp/key
TUNNEL_PORT=$1
COMMENT=$2

rm -rf tmp
mkdir tmp
ssh-keygen -q -t rsa -b 1024 -f tmp/key -N "" -C ra-$TUNNEL_PORT-$COMMENT-`date '+%Y%m%d%H%M%S'`
sed -i 's|^|no-X11-forwarding,no-agent-forwarding,no-pty,permitopen="127.0.0.1:65534",command="~/bin/from-remote '$TUNNEL_PORT'" |' tmp/key.pub
echo "post" > tmp/host
echo "22" > tmp/port
echo "alex" > tmp/user
echo $TUNNEL_PORT > tmp/tunnelport
tar -czf remote-access.tar.gz -C tmp host port user tunnelport key --owner root --group root
echo "Run the following command to allow login with the newly-generated key." 1>&2
echo "cat `realpath tmp/key.pub` >> ~/.ssh/authorized_keys"