
gnome ターミナルタブからインターネット経由でサーバーに SSH 接続する場合、インターネット接続が切断されるとターミナルタブが停止し、入力は許可されません。なぜ停止しますか?
ターミナルタブを有効にする方法はありますか?つまり、ローカルシェルプロセスを引き続き実行させますか?
ターミナルタブを閉じることは唯一の方法ですか?
答え1
ClientAliveInterval
SSH接続は、ClientAliveCountMax
パラメータとそのクライアントによって設定された指定された時間が経過すると自動的に切断されます。これらのタイムアウトがかなり長い場合、シェルが停止する現象が発生します。ただし、次のように使用すると、タイムアウトOpenSSH
を待つ必要はありません。エスケープ文字:
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.
(...)
接続が停止したら(+キーを一緒に~意味する)押し、手を離して押します。または、接続が不安定な場合、または常にリモートサーバーに接続する必要がある場合は、次のものを使用できます。Shift`.自動SSH切断された接続を自動的に復元して非常に便利です。
編集する:
ただし、ClientAliveInterval
両方が明示的ServerAliveInterval
にゼロに設定されているか、明示的に設定されていない場合、タイムアウトsshd_config
設定ssh_config
は次のファイルで設定されます(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.
簡単に使用して、これら3つのファイルを変更し、echo
この値に基づいて固定SSHセッションが切断されたことを直接確認できます。