Pregunta:
cuando me dirijo a un servidor a través de Internet en una pestaña de terminal de gnome, si pierdo la conexión a Internet, la pestaña de terminal se colgará y no aceptará ninguna entrada. ¿Por qué está colgado?
¿Hay alguna forma de activar la pestaña del terminal, es decir, hacer que continúe ejecutando el proceso de shell local?
¿Cerrar la pestaña del terminal es la única forma?
Respuesta:
La conexión SSH se interrumpe automáticamente después de un período de tiempo específico establecido por los parámetros ClientAliveInterval
y ClientAliveCountMax
y sus equivalentes del lado del cliente. Si estos tiempos de espera son bastante altos, experimentará un caparazón congelado. Sin embargo, si usa OpenSSH
, no tiene que esperar un tiempo de espera y puede forzar el cierre de una conexión usando caracteres de escape :
ESCAPE CHARACTERS
When a pseudo-terminal has been requested, ssh supports a number
of functions 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 character can be changed in configuration files using the
EscapeChar configuration directive or on the command line by the
-e option.
The supported escapes (assuming the default ‘~’) are:
~.
Disconnect.
(...)
Cuando la conexión se congele, presione ~ (eso significa Shift + ` teclas juntas), suéltelo y presione . . Alternativamente, si trabaja con una conexión inestable o necesita estar conectado al servidor remoto todo el tiempo, puede usar autossh para renovar automáticamente la conexión perdida, es muy conveniente.
EDITAR :
Sin embargo, si tanto ClientAliveInterval
como ServerAliveInterval
se establecen en 0 explícitamente o no se establecen explícitamente y luego se establecen en 0 de forma predeterminada de acuerdo con las ssh_config
manual de sshd_config
y ssh_config, la configuración de tiempo de espera se establece en los siguientes archivos (de http://tldp.org/ HOWTO / TCP-Keepalive-HOWTO / usingkeepalive.html ):
# cat /proc/sys/net/ipv4/tcp_keepalive_time
7200
# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
75
# cat /proc/sys/net/ipv4/tcp_keepalive_probes
9
The first two parameters are expressed in seconds, and the last is
the pure number. This means that the keepalive routines wait for
two hours (7200 secs) before sending the first keepalive probe,
and then resend it every 75 seconds. If no ACK response is
received for nine consecutive times, the connection is marked as
broken.
Puede modificar estos 3 archivos con solo usar echo
y ver que una sesión SSH congelada se desconecta de acuerdo con estos valores.