It is often required that, for security reason, you have to hop through a SSH gateway to access other machines. While this is perfectly fine and simple to do, it is often cumbersome to open a new session. However, with a small script you can speed up your access to machines even with such a restriction in place.
Classical way of hop’ing
Let’s say our gateway is named
gateway and our target
myAppHost the classical way of doing it would be :
Faster way of hop’ing
A quicker way of doing this is to specify the ssh command directly, there is one thing to tell ssh though: allocating a TTY even if it does not seem to be connected to one. In fact, the command supplied to ssh is not supposed to be interactive, that is why you need to give this hint to SSH :
Script this !
The script is really simple, and only consists in the following
Save this in your path and give it the run permission then you are
all set (mine is named
gssh). All you have to do to
connect is now a simple