route ssh through a series of hosts (for if you / the servers are behind firewalls etc)
route ssh through a series of hosts i.e. multi-hop (for if you / the servers are behind firewalls etc)
This is a script to enable you to route ssh though a series of host to connect to your final host, and then either run as standard SSH, have a forward proxy, or run a command
The script works by creating a temporary ssh config file, with all the parameters needed, then running ssh with that. This enables you to then easily create a socks proxy or whatever you need
### Example 1 : Traversing a single machine
If you want to connect
* to a remote host called ``destination`` (as user ``chuck``, on default port)
* via a firewall (as user ``jane``, on non-default port 1727)
The corresponding command using rssh is :
$ rssh jane@firewall:1727 chuck@destination
If you have the firewall and destination defined on your ssh config then it would simply be
$ rssh firewall destination
## Example 2 : traversing through two machines
If you want to connect
* to a remote host called ``destination`` (as user ``chuck``, on default port)
* via a firewall (as user ``jane``, on non-default port 1727)
* then via a router (as user ``bill``, on default port)
Again, if you have the firewall, router and destination defined on your ssh config then it would simply be
$ rssh firewall router destination
### Example 3 : Traversing through a single machine and setting up a socks proxy in the final destination server
If you want to connect
* to a remote host called ``destination`` (as user ``chuck``, on default port) and have a Socks proxy on port 8889
* via a firewall (as user ``jane``, on non-default port 1727)
The corresponding command using rssh is :
$ rssh jane@firewall:1727 chuck@destination -8889
If you have the firewall and destination defined on your ssh config then it would simply be
$ rssh firewall destination -s 8889
### Using 'common' settings from bashrc on the destination server.
If you add your bashsettings into a file at ~/.sshrc then these will be used on the destination server (temporarily whist you are logged on). So if you want to include your favourite aliases, functions etc into ~/.sshrc then they will be available to you when logged into the destination server
( incorporating the code from https://github.com/Russell91/sshrc )