SSH Hop Through Multiple Hosts

SSH Hop Through Multiple Hosts

I frequently need to ssh through multiple hosts to get to a destination.  Frankly this is not really a problem, but there is a simpler way, and I like simpler.  This is a really straight forward article, not a lot of explanation is really necessary.  Sometimes I need to use this when I am connecting through hosts that are not fully routed, or perhaps to get to a secure network – where you must traverse a firewall.

2 Host Hop

# ssh -t user@host1 "ssh user@host2"

2 Host Hop with X Redirection

# ssh -t -X user@host1 "ssh -X user@host2"

3 Host Hop

# ssh -t user@host1 "ssh -t user@host2 'ssh user@host3'"

3 Host Hop with X Redirection

# ssh -t -X user@host1 "ssh -t -X user@host2 'ssh -X user@host3'"

Using these different ways you can extend your reach using ssh to reach through hosts.