blob: a67c873673ae6d658374a5898c4c53e8a5384de4 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/bin/sh
# opens a ssh tunnel and starts a new firefox instance
# configure your firefox profil to use the ssh tunnel
user=$USER
host=$(hostname)
port=9999
url=$user@$host
while [ $# -ne 0 ]; do
case "$1" in
-u|--url)
if [ "x$2" = "x" ]; then
echo "$1 requires an argument. Abort." 1>&2
exit 1
else
url="$2"
fi
shift
shift
;;
-h|--host)
if [ "x$2" = "x" ]; then
echo "$1 requires an argument. Abort." 1>&2
exit 1
else
host="$2"
fi
shift
shift
;;
-p|--port)
if [ "x$2" = "x" ]; then
echo "$1 requires an argument. Abort." 1>&2
exit 1
else
port="$2"
fi
shift
shift
;;
*)
echo "Usage: '$(basename $0) [-u HOST] [-p PORT]'"
echo "Default connection is set to $url:$port"
exit 1
esac
done
if [ "x$host" = x ]; then
echo "No host given. Abort." 1>&2
exit 1
fi
if [ "x$port" = x ]; then
echo "No pott given. Abort." 1>&2
exit 1
fi
if [ x$(netstat -tulpen 2>/dev/null | grep 127.0.0.1:$port | head -1 | cut -d "/" -f2) = "xssh" ]; then
echo "Using existing ssh tunnel."
else
nohup ssh -f -N $url -D $port >>/tmp/nohub.ssh$port.log 2>&1 &
if [ $? -ne 0 ]; then
echo "Failed to create the ssh tunnel. Read /tmp/nohub.ssh$port.log for more information."
exit 1
fi
fi
nohup firefox -no-remote -P proxy >>/tmp/nohub.fx.log 2>&1 &
if [ $? -ne 0 ]; then
echo "Failed to start Firefox. Read /tmp/nohub.fx.log for more information."
exit 1
fi
echo "Proxying all traffic through '$url:$port'."
exit 0
|