
will leave you in Machine1, and Enter ~ ~ ~. will get you back to your local session, Enter ~ ~. you ssh from local->Machine1->Machine2->Machine3), Enter ~. For example, if you're nested in 3 levels, (i.e.

Enter ~ Ctrl+ Z to send the ssh client to the background job queue of your local shell, then fg as normal to get it back.Įdit: When dealing with nested SSH sessions, you can add multiple tilde characters to only break out of one of the SSH sessions in the chain, but retain the others. There are also various things you can do such as setting keep-alive timeouts in your client so that if it doesn't have an active link for a certain amount of time it shuts off on it's own, but the default behavior is to stay as connected as possible!Įdit: Another useful application of this interrupt key is to get the attention of the local ssh client and background it to get back to your local shell for a minute -say to get something from your history- then forground it to keep working remotely. Of course you can specifically tell it to give up and die with the sequence above. If the network breaks, sometimes even days later you can get an SSH session back. The long-hang behavior on communication issues is not a bug, the SSH session is hanging out hoping the other side will come back. The tilde (only after a newline) is recognized as an escape sequence by the ssh client, and the period tells the client to terminate it's business without further ado. There is a "secret" keyboard shortcut to force an exit :~) From the frozen session, hit these keys in order: Enter ~.
