summaryrefslogtreecommitdiff
path: root/rapid-tunneling
blob: 02ae4e75e5c7226d6f40cd84a33c42354191ecb0 (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
25
26
27
#!/bin/sh

if [ -z "$1" ]; then
	echo "Usage: $0 <remote-access-file-name>" 1>&2
	exit 1
fi

rm -rf /tmp/ra
mkdir -m 700 /tmp/ra
mkdir /tmp/ra/recv /tmp/ra/send
gunzip -cf $1 | tar xf - -C /tmp/ra/recv
dropbearconvert openssh dropbear /tmp/ra/recv/key /tmp/ra/recv/key.db
chmod 600 /tmp/ra/recv/key.db
user=`cat /tmp/ra/recv/user`
host=`cat /tmp/ra/recv/host`
port=`cat /tmp/ra/recv/port`
tunnelport=`cat /tmp/ra/recv/tunnelport`

dropbearkey -t rsa -f /tmp/ra/send/key.db | grep '^ssh-rsa ' > /tmp/ra/send/key.pub
dropbearconvert dropbear openssh /tmp/ra/send/key.db /tmp/ra/send/key
cp /tmp/ra/recv/key /tmp/ra/send/origkey
tar czf /tmp/ra/send/ra-params.tar.gz -C /tmp/ra/send key origkey

mkdir -m 700 /tmp/ra/.ssh
cat /tmp/ra/send/key.pub >> /tmp/ra/.ssh/authorized_keys
chmod 644 /tmp/ra/.ssh/authorized_keys
start-stop-daemon -S -b -x /bin/sh -- -c "ssh -y -K 10 -T -p $port -i /tmp/ra/recv/key.db -R $tunnelport:127.0.0.1:22 -l $user $host < /tmp/ra/send/ra-params.tar.gz"