wow, freaky checkin from accidental work time spent in usb flash drive, rather than
[feisty_meow.git] / scripts / security / start_tunnels.sh
1 #!/bin/bash
2 # this script makes a tunnel for SMTP traffic and others.  a remote ssh server
3 # is required.  this is especially useful for routing around firewalls using
4 # a web proxy like squid.  when used for SMTP, it ensures that none of the
5 # text is seen on whatever network one is on before it's sent from the remote
6 # server.
7
8 #hmmm:  none of the user info below will work for others: parameterize it.
9
10 #hmmm: maybe we need a base function that takes all the disparate values,
11 #      and this script could call it with known feisty meow settings.
12
13 ##############
14
15 # these variables are configurable from plug-ins.
16
17 soundfile=$FEISTY_MEOW_DIR/database/sounds/woouoo.wav
18 if [ ! -z "$1" ]; then
19   soundfile=$1
20 fi
21
22 ##############
23
24 # provides a list of properly formatted tunnels for ssh to create.  if this list
25 # is empty, then we do nothing.
26 # TUNNEL_LIST=()
27
28 # set this to the hostname that will be providing the tunnel.  this is
29 # usually a remote system.
30 USER_PLUS_HOST=""
31
32 # set this to your key file, plus the -i flag, such as: 
33 #   SECURITY_KEY="-i $HOME/.ssh/id_rsa" 
34 SECURITY_KEY=""
35
36 ##############
37
38 #hmmm:move to fred configs!
39 TUNNEL_LIST+=(-L 14008:localhost:25)
40 USER_PLUS_HOST="fred@serene.feistymeow.org"
41 SECURITY_KEY="-i $HOME/.ssh/id_dsa_fred" 
42
43 ##############
44
45 while true; do
46   echo Connecting sendmail to serenely zooty.
47   ssh  -2 -N -v ${TUNNEL_LIST[*]} "$USER_PLUS_HOST"
48   bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh $soundfile &>/dev/null </dev/null &
49 #hmmm: parameterize this for the sound to be played.  doofus.
50   echo "Got dumped from tunnels; re-establishing connection."
51   echo "Note: if you're being asked for a password, you haven't set up an RSA key yet."
52   sleep 14
53 done
54
55 #-L 8028:localhost:3128 
56
57 #-L 8043:localhost:443 
58
59 # ports sometimes used:
60 #     25 is the sendmail tunnel.
61 #   3128 is the squid proxy server.
62 #    443 is the https version of squid.
63
64 # ssh flags in use sometimes:
65 #   -f   go into the background once connected.
66 #   -2   enforce ssh version 2.
67 #   -N   don't execute any command; just forward data between the ports.
68 #   -L   (port:host:hostport) connect the local machine's "port" to the
69 #        remote port "hostport" on the "host" specified.  the local "port"
70 #        becomes an alias for the remote port.  note that the connection
71 #        being made to host and hostport is from the perspective of the ssh
72 #        server, not the local host.
73
74