forked from wazum/openconnect-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect
executable file
·47 lines (40 loc) · 1001 Bytes
/
connect
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
42
43
44
45
46
47
#!/bin/bash
# Edit this
OPENCONNECT_USER=
OPENCONNECT_URL=
OPENCONNECT_OPTIONS="--authgroup <VPN Group> --servercert <VPN Server Certificate>"
PROXY_PORT=8888
# Don't touch this
container() {
# Ask for password on the commandline
stty -echo
printf "VPN password: "
read OPENCONNECT_PASSWORD
stty echo
printf "\n\n"
# Start container with proxy on specified port
docker run -it --rm "$@" --privileged \
-e OPENCONNECT_URL="$OPENCONNECT_URL" \
-e OPENCONNECT_OPTIONS="$OPENCONNECT_OPTIONS" \
-e OPENCONNECT_USER="$OPENCONNECT_USER" \
-e OPENCONNECT_PASSWORD="$OPENCONNECT_PASSWORD" \
-e PROXY_PORT="$PROXY_PORT" \
-p $PROXY_PORT:$PROXY_PORT \
"wazum/openconnect-proxy:latest"
}
ssh_proxy() {
if hash corkscrew 2>/dev/null; then
ssh -o ProxyCommand="corkscrew 127.0.0.1 $PROXY_PORT %h %p" "$@"
else
printf "The ssh command requires 'corkscrew' to be installed and executable.\n"
fi
}
case $1 in
ssh)
shift
ssh_proxy "$@"
;;
*)
container "$@"
;;
esac