特定の時間後に対話型SSHセッションを終了する方法

特定の時間後に対話型SSHセッションを終了する方法

私の/etc/ssh/sshd_configファイルに次のパラメータを設定しました。

ClientAliveInterval 10
ClientAliveCountMax 3

これで、ホストコンピュータのマイsshサーバー(my)ファイルを/etc/ssh/sshd_config変更しました。その後、次のコマンドsshを実行してサービスを再起動しました。

/etc/init.d/sshd reload

30秒後に接続が切断されると予想していましたが、ssh今はほぼ1時間ほど続いています。

誰かがここで何が起こっているのか教えてもらえますか?

OpenSSHバージョン6.1を使用しています。

ベストアンサー1

SSH設定を使って欲しいものが得られないと思います。ClientAlive*SSHクライアントとSSHサーバー間の接続が応答しなくなったときに両側が待機する時間の設定(明らかにクライアントタイムアウト)。

代わりに、Bashの$TMOUT環境変数を使用して、一定時間が経過すると接続を切断するようにシェルに指示します。

TMOUT  If  set  to  a  value greater than zero, TMOUT is treated as the 
       default timeout for the read builtin.  The select command terminates 
       if input does not arrive after TMOUT seconds when input is  coming  
       from  a  terminal.   In  an interactive  shell,  the value is 
       interpreted as the number of seconds to wait for input after issuing 
       the primary prompt.  Bash terminates after waiting for that number of 
       seconds if input does not arrive.

引用する

おすすめ記事