How to close a frozen SSH session?

Sometimes an SSH session on a remote server will hang indefinitely due to poor internet connection. Is it possible to close a session without closing the terminal?

+6
source share
2 answers

Press the following three keys:

  • Enter
  • ~ (tilde)
  • . (Period)

This is the disable function, as described in the ESCAPE CHARACTERS section of the ssh man page.

+12
source

In this geekosaur post, we suggest using escape sequences as follows: "To kill the current session, Enter ↵ , ~ ,.

More of these escape sequences can be specified using Enter ↵ , ~ ,? :

 Supported escape sequences: ~. - terminate session ~B - send a BREAK to the remote system ~R - Request rekey (SSH protocol 2 only) ~# - list forwarded connections ~? - this message ~~ - send the escape character by typing it twice (Note that escapes are only recognized immediately after newline.) 

You can close the list of Escape sequences by pressing enter .

Note that since pressing ~ ~ causes ssh to send ~ instead of intercepting it, you can access N nested ssh connections by pressing ~ N times. (This only applies to ~ s, which immediately follow enter .) That is, enter ~ ~ ~ ~ ~ ~ . terminates the ssh session 5 layers deep and keeps the other 4 intact. "

+3
source

Source: https://habr.com/ru/post/983629/


All Articles