SSHRoute

About

SSHRoute is a simple tool for creating SSH tunnel scripts that use a number of intermediate servers. If you need SSH tunnels to access certain resources and must do it via another machine, you will probably end up with scripts like the following:

ssh -L80:localhost:60080 user@host1 -t "ssh -L60080:localhost:80 user@host2"

As you can imagine, if forwarding many ports or going through many hosts, writing these can get complicated and tedious. SSHRoute does this for you.

Usage

sshroute.py [PORTS] [HOSTS] [OPTIONS] DESTINATION

Ports are of the format -l start:intermediate:dest or -r start:intermediate:dest for 'local' and 'remote' tunnels respectively - these correspond to the -L and -R for ssh itself. start is the port number for the endpoint which connections are going to be made to, and dest is the port number for the final destination of the connection. intermediate is the port number used on all machines in between the local host and the DESTINATON.

Hosts are of the format -h [username@]hostname[:port] (the username and port parts are optional). All hosts except for the destination should be specified with -h options. The destination follows the same format.

The only other option supported at the moment is -s, which adds the #!/bin/bash -i shebang to the beginning of the output. This way, you can redirect the output to a file and use it as a script.

sshroute.py -l80:60080:80 -h host1 -h host2 user@host3:2222 -s > httpforward.sh
chmod +x httpforward.sh
./httpforward.sh

Download

The latest version of SSHRoute can be downloaded from the SubVersion repository at scripts/sshroute.py.

Last modified April 13th, 2008 at 2:50 a.m.