Sometimes an SSH session to a remote server will freeze indefinitely due to bad internet connectivity. Is it possible to close the session without closing the terminal?
If you want to terminate an interactive OpenSSH session which is stuck and cannot be exited by entering exit or Ctrl D into a shell on the remote side, you can enter ~ followed by a dot . . To be sure to enter the escape character at the beginning of an input line, you should press Enter first.
Option 2: bg + disown. If you want to "background" already running tasks, then Ctrl + Z then run bg to put your most recent suspended task to background, allowing it to continue running. disown will keep the process running after you log out.
Use 'SIGKILL' or '9' with the kill command to terminate a process. For instance: All users need to be logged out of system before we trigger a monthly job. To kill multiple ssh sessions running in system.
To end the Putty session, type the logout command such as exit or logout. This command might vary between servers. You can close the session by using the Close button.
Press the following three keys:
This is the "disconnect" function as described in the ESCAPE CHARACTERS
section of the ssh
man
page.
In this post, geekosaur suggests we use the escape sequences as follows: "To kill the current session hit subsequently Enter ↵, ~, ..
More of these escape sequences can be listed with 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 hitting Enter ↵.
Notice that because hitting ~~ causes ssh
to send the ~
instead of intercepting it, you can address N nested ssh
connections by hitting ~ N times. (This only applies to ~s that directly follow an Enter ↵.) That is to say that Enter ↵~~~~~. terminates an ssh
session 5 layers deep and keeps the other 4 intact."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With