【macOS】 SSH セッション切れ対策(Write failed: Broken pipe, packet_write_wait: Connection 防止)

2021-06-18

SSHクライアントは、Windowsの時は Tera Term を使ってましたが、macOS では
標準のターミナルソフトとiTerm2を使用しています

標準ターミナル・iTerm2を使用していて少し長めに離席したりして、操作をしない時間があると「Write failed: Broken pipe」や「packet_write_wait: Connection〜〜」のエラーがでて接続切れることがあります

Write failed: Broken pipe
packet_write_wait: Connection to xxx.xxx.xxx.xxx port xx: Broken pipe

標準のターミナルソフトの対策

keepAliveの設定を変更すると解消する場合があるので、ssh/configを以下のように設定しました
設定自体は、「~/.ssh/config」に ServerAliveInterval 60 (60秒毎に)を設定
OS X El Capitan導入後、接続切れが発生したので、「ServerAliveCountMax 15」も追記設定しました
クライアントのSSH設定のため、iTerm2を利用する場合でも設定をした方がセッション切れは発生しにくくなります

$ vi ~/.ssh/config
Host *
ServerAliveInterval 60
ServerAliveCountMax 15
$ chmod 600 ~/.ssh/config

iTerm2の対策

iTerm2でのセッション切れの対策は、
上部メニューより[profiles] → [open profiles] で標準で使っているprofileを選択
[edit profiles] → [session] を表示して、[when idle send ASCII code]にチェックをいれます。
入力する数字は、0から20の中で任意の数字を入れます
自分は設定を、When idle, send ASCII code 「0」 every 「60」 secondsを設定しています

スポンサーリンク

0
0

MacMac OSX,macOS,MGX82J/A

Posted by admin