0
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 2017-07-07

 sshサーバとクアイアント間で、それぞれから接続維持を確認するパケットを、一定の秒間隔で送信することができる。介在するルータやファイアウォールの設定で、一定時間以上通信がない場合に切断されてしまう事態を回避することができる。サーバー側から発信する場合は /etc/ssh/sshd_config に以下の2行を書き込み、sshdを再起動する。

# ls -l /etc/ssh/sshd_config
-rw-------. 1 root root 3872 Sep  7  2011 /etc/ssh/sshd_config
# vi /etc/ssh/sshd_config	# ClientAliveInterval と ClientAliveCountMax を設定
# grep ClientAlive /etc/ssh/sshd_config
ClientAliveInterval 1024
ClientAliveCountMax 4
# /etc/init.d/sshd restart

 通常は、サーバー側からではなく、クライアント側から発信すればよい。その場合 ~/.ssh/config に以下の2行を書き込み、sshを実行する。

$ ls -l ~/.ssh/config 
-rw------- 1 glire glire 47 Jul  8 01:34 /home/w3glires/.ssh/config
$ cat ~/.ssh/config
ServerAliveInterval 1024
ServerAliveCountMax 4
0
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
0
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?