If you find yourself trapped inside a SSH session that is hung, while SSH’d into another machine? I have, often actually. Sometimes I’m connected and reading up on something and when I come back my session has loss its connection while I was ssh’d into another machine. Here’s how you can back out to the other machine:
In the shell type: ~.
that’s a period at the end of the tilde. This will terminate your connection and bring you back to the shell you where SSH’d into prior to that.