summaryrefslogtreecommitdiff
path: root/bin/extra/aivpn
blob: fd72ffb3b205022ecaeeb7d6c0d049f980f8774c (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

logn() { printf "%s\n" "$@"; }

if [ "$1" = "-k" ]
then
	pgrep -f -- "ssh.*-L.*vm" |
		xargs kill
	exit
fi

# For when script calls itself
if [ "$PASSWORD" ]
then
	pass show "$PASSWORD" &&
		exit
	exit 1
fi

keyadd ehb/ai

export SSH_ASKPASS="$0"
export SSH_ASKPASS_REQUIRE="prefer"
export PASSWORD=zot/qemu

logn "I: Waiting for connectivity..."
while ! ssh -o ConnectTimeout=1 -o BatchMode=yes vm 2>&1 | grep -q "Permission denied"
do sleep 1
done

logn "I: Activating vpn"
ssh vm "rasdial \"vpn.student.ehb.be\""
ssh -f -N \
	-L 2222:10.2.160.41:22 \
	vm

ssh -t \
	-L 8188:localhost:8188 \
	vm \
	ssh -N -L 8188:localhost:8188 luca@10.2.160.41
logn "[8188], [2222]"