ssh-chain wasn’t written
by me, but it’s so incredibly useful and I use it a lot, which makes
it a perfect fit to be listed here.
Often (admittedly, with the advent of IPv6 less often) you want to
ssh to a machine you can’t connect to directly, and have to “hop”
over a proxy host. Many people configure such hops statically in
.ssh/config, for example (the latter variant works with modern
versions of OpenSSH only):
Host office ProxyCommand ssh -qAx remote.example.org nc -q5 workstation.example.org 22 Host office2 ProxyCommand ssh -W workstation.example.org:22 remote.example.org
However, these configurations get nasty quickly if you need multiple hops or want to use different hops depending on other things.
ssh-chain is a simple Perl script you put into
the path of your remote machines, and add the following line to
Host *^* ProxyCommand ssh-chain %h %p
Now, you can use that host to hop to other machines over SSH, by just
giving a “path” (think UUCP ;)) of immediate hosts (which all need
ssh is so central to many tools, this syntax also works for
git, and many others. Really useful if you work
with non-trivial network topologies.