Using a ssh tunnel and local socks proxy in a browser is a convenient way to access journal pages that check for the IP range of the university. This script opens a ssh tunnel and launches a chromium session with the according proxy sessions.

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
#!/bin/bash
if [ "$#" -ne 1 ]; then
    echo  "Need ssh address as parameter, e.g. $0 myserver.com"
		exit 1
fi

#cluster to access
cluster=$1
echo "Trying to opening tunnel to $cluster."

# Start at some port
port="8042"
scanning=true

nco=`netstat -an`
while $scanning
do
	echo " - Checking port $port ..."
	if [[ "$nco" != *":$port"* ]]; then
		echo "     port free."
		echo "Use Ctrl+C to exit connection and stop chromium."
		echo
		chromium --proxy-server="socks5://localhost:$port" &
		scanning=false
		cpid=$!
		trap "echo 'Stop chromium ...'; kill $cpid;" EXIT
		ssh -N -D localhost:$port $cluster
	fi
	if [ $port -lt 9000 ]; then
		port=$[$port+1]
	else
		echo "No free port found. Aborting"
		scanning=false
	fi
done