ssh – host hopping (with Jump host)
2018-08-20
169 words
1 min read
Most of the times I need to jump hosts with ssh. What do I mean by that. Let me try to explain :
If I need to got to host h3 then I need to first login to h1 and from there to host h2 and finally to host h3. This can be done with .ssh/config file but for that I need to have some program like nc installed on all the hosts in between which might not be practical in all cases. So, here is something that I found very useful.
ssh -tt h1 ssh -tt h2 ssh -tt h3
In the above command, we can add usernames, if needed. And now for the best part, if we add entry for h2 in h1 and h3 in h2 in the .ssh/config file, then we don’t need to add usernames. Similarly setup passwordless ssh from h2 to h3 and h1 to h2 and you don’t need password for any of the hosts, how cool is that 🙂
Related Articles:
- 2011/09/07 ss – utility to investigate sockets.
- 2011/08/29 [Solved] ssh works but scp does not
- 2018/02/26 Send history of current host to some other host over ssh
- 2016/04/04 ssh – remove offending key.
- 2015/09/21 Executing commands on multiple hosts
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.