Suppose I am working on LocalA
(username userA
). I use ssh
to tunnel to RemoteB
(username userB
), then to RemoteC
(username userC
), then finally to RemoteDestinationD
(username userD
).
It would look something like the following:
userA@LocalA$ ssh userB@RemoteB
userB@RemoteB$ ssh userC@RemoteC
userC@RemoteC$ ssh userD@RemoteDestinationD
userD@RemoteDestinationD$
Suppose I forget which series of connections I used to connect from LocalA
to RemoteDestinationD
. It could have been one jump (e.g. userA@LocalA$ ssh userD@RemoteDestinationD
) or three jumps (as in my example above). How could I programmatically determine what my series of jumps was? ("Scroll through your history, dummy!" doesn't count....)
I'd like a BASH script that would output something like the following:
userA@LocalA$ --> userB@RemoteB
userB@RemoteB$ --> userC@RemoteC
userC@RemoteC$ --> userD@RemoteDestinationD
Any ideas?
Thanks in advance!