1. カメラ
  2. カーオーディオ&エレクトロニクス
  3. ホームオーディオ
  4. パーソナルオーディオ
  5. テレビ
  6. スマートホーム
  >> 電子技術オンライン >  >> スマートホーム >> スマートライフ

SSH のデフォルト タイムアウトとは?

Secure Shell は、Linux、OS X、および Windows で利用できるコンピューターまたはサーバーをリモートで管理する方法です。 SSH セッションが開いていて無人であるとセキュリティ上のリスクが生じるため、一定の間隔で SSH セッションがタイムアウトします。一定時間操作を行わないと、接続が切断され、再度ログインする必要があります。このタイムアウトはシステムの TCP 設定によって定義されますが、サーバー設定またはクライアント設定でオーバーライドできます。 SSH 接続が頻繁にタイムアウトする場合は、いつでも SSH 構成を編集して、非アクティブな時間を増減できます。

TCP タイムアウト

サーバーのタイムアウトは、デフォルトでシステムの TCP タイムアウトになります。これは、SSH サーバーが TCPKeepalive を使用するように自動的に構成されているためです。TCPKeepalive は、システムがアイドル状態の事前設定された時間にプローブを送信して、接続がまだそこにあることを確認します。このデフォルトは、システムによって異なります。システムによっては、デフォルトで 5 秒まで使用するものもあれば、2 時間まで使用するものもあります。通常、平均は約 3 ~ 5 分です。サーバー側またはクライアント側のいずれかでタイムアウトを変更するように変更されていない場合、SSH 接続はこのタイムアウトを使用します。サーバーまたはクライアントの設定は、このタイムアウトをオーバーライドします。

サーバー全体のタイムアウト設定

sshd_config ファイルからタイムアウトを編集すると、サーバーにログオンするすべてのクライアントのタイムアウト オプションが変更されます。システム管理者は、/etc/ssh/sshd_config でこのファイルにアクセスできます。ターミナルを使用していて、ターミナル エディタに慣れている場合は、「sudo nano /etc/ssh/sshd_config」と入力して、ターミナル全体を編集できます。アクティビティをチェックするためにデータのパケットをクライアントに送信するようサーバーに指示するオプション「ClientAliveInterval」を追加します。 「ClientAliveCountMax」も追加することを検討する必要があります。これにより、応答を取得せずに何回チェックする必要があるかがサーバーに通知されます。これらの前にポンド記号を付けないでください。ポンド記号が先頭にある行はコメントと見なされ、サーバーでアクティブなオプションではありません。たとえば、ClientAliveInterval を 5 分に設定し、ClientAliveCountMax を 2 に設定する場合、次のようになります:ClientAliveInterval 300ClientAliveCountMax 2

クライアントベースのタイムアウト

If you're using a client like Putty, you can change the timeout by clicking the "Connection" option on the sidebar and fill in your preferred time in the text box beside "Seconds Between Keepalives" in seconds. This should be based on entirely how long you think you'll be inactive between activity. You can also change this manually by opening your client-side setting files at /etc/ssh/ssh_config – note the difference between the server file "sshd_config". Add the setting "ServerAliveInterval" and set in seconds how often you want to the client to send packets to keep the connection active.

Risks of Changing Timeout

Obviously changing timeout is a matter of convenience – it allows you to multitask without having to frequently renew your login to your SSH server. However, this means that you need to remain more vigilant at your desktop. If you walk away from your computer with an SSH connection open, anyone can sit down and access your server. While leaving an SSH connection open for home use is less concerning than when you're doing so for you, being in the habit of leaving your connection open can have quite horrible consequences in the wrong hands.