2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SSH接続の一定時間切断を解消する

Last updated at Posted at 2019-02-24

環境

  • Windows 7
  • Git Bash

※サーバーへのSSH接続に必要な準備・設定等はすでに済んでいるものとみなして話を進めます。

SSH接続してしばらく作業せずにいると、以下の表示とともに接続が切れてしまうことがあります。

Connection reset by ~~~~~ port ~~~~~

何度も接続し直すのは面倒くさいため、設定ファイルを更新して接続の自動切断を解消しましょう。
その場合はまず「Git Bash」を起動し、以下のコマンドを実行してファイルをエディタで開きます。

注意点として「Git Bash」を開く際は「C:\Users[ユーザー名]」となる位置で開いた上で下記コマンドを実行してください。

設定ファイルをエディタで開く
vi .ssh/config

「vi」はLinuxの標準テキストエディタを起動するコマンドです。
クライアント側の設定ファイルが開かれたら、以下の一行を追記しましょう。

サーバへの応答確認を15秒ごとに送る設定
ServerAliveInterval 15

追記が完了したら「:wq」で上書き保存し、ファイルを閉じましょう。
「:wq」キーは「ファイルを保存しviを終了する」ためのコマンドです。
設定はこれで以上です。

改めてSSH接続し、自動で切断されるか否か確認してみてください。

以下のサイトを参考にさせていただきました

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?