E
Eric Hansen
Guest
More often than not when I leave an SSH session running for a period of time without input the session will hang. By this I mean I can type whatever I want and nothing will echo back. It can be very annoying, especially since I would have to open up a new terminal on my machine, SSH to the server I was on and kill that process.
There is, however, another trick that I just discovered and can save a lot of extra work. Lets look at the documentation real quick though for SSH to understand how this trick will work:
By default a pseudo-terminal is always allocated to SSH sessions but if you wish to enforce this pass the "-t" switch when running SSH.
If you notice above the list of codes there must be a newline before using the code. Luckily all this means is you hit Enter then the code you want to use (~. in our case). So what you would do is this:
There is, however, another trick that I just discovered and can save a lot of extra work. Lets look at the documentation real quick though for SSH to understand how this trick will work:
If a pseudo-terminal has been allocated (normal login session), the user may use the escape characters noted below.
By default a pseudo-terminal is always allocated to SSH sessions but if you wish to enforce this pass the "-t" switch when running SSH.
Above is a list of all the special codes you can use. The one we're interested in is the "~." command.When a pseudo-terminal has been requested, ssh supports a number of func-
tions through the use of an escape character.
A single tilde character can be sent as ~~ or by following the tilde by a
character other than those described below. The escape character must
always follow a newline to be interpreted as special. The escape charac-
ter can be changed in configuration files using the EscapeChar configura-
tion directive or on the command line by the -e option.
The supported escapes (assuming the default '~') are:
~. Disconnect.
~^Z Background ssh.
~# List forwarded connections.
~& Background ssh at logout when waiting for forwarded connection /
X11 sessions to terminate.
~? Display a list of escape characters.
~B Send a BREAK to the remote system (only useful for SSH protocol
version 2 and if the peer supports it).
~C Open command line. Currently this allows the addition of port
forwardings using the -L and -R options (see above). It also
allows the cancellation of existing remote port-forwardings using
-KR hostport. !command allows the user to execute a local com-
mand if the PermitLocalCommand option is enabled in
ssh_config(5). Basic help is available, using the -h option.
~R Request rekeying of the connection (only useful for SSH protocol
version 2 and if the peer supports it).
If you notice above the list of codes there must be a newline before using the code. Luckily all this means is you hit Enter then the code you want to use (~. in our case). So what you would do is this:
- Hit the Enter key
- Hold shift and hit ` (so you send the ~ key)
- Hit . (period)