I can ssh to multiple servers but once I've reached one of them, I can't ssh to the next I have to go back to my local machine and then ssh to the next server. I would like to set up a script that lives on each these servers that can exit and then ssh to the next arbitrary server. I've tried setting up an alias for this.
like so: alias host2="exit; ssh host2;"
that didn't get me anywhere, Then I spent a long time looking into the localcommand config for ssh and I don't think that can help me either. Most recently I've been looking into writing a script that suspends the ssh instance and drops you local again, but I can't seem to get the formatting right for echoing ~ ^Z. Even if I could I'm not sure it would help. Now my only thought is that maybe the remote server could scp the host name to a shared location and once back I could check that file if it has anything I use that as my next server. But I'm guessing there is a way easier way. Anyways any ideas or insights would be much appreciated thank you!