When the management server using SSH,If you are a long time without having to log on,Then it is likely that awaits you is
"Write failed: Broken pipe”
Cause the cause of this error is the result of SSH link has been idle too long,so,SSH we need to change the default configuration to have it automatically turn off link。
In the SSH configuration,There are two commands to do this function,They are:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
//ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server. This option applies to protocol version 2 only. //ClientAliveInterval Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client. This option applies to protocol version 2 only. |
Both commands applications on the client,The latter application on the server,If you do not have administrator privileges,The former is a good choice。
These two features are the same,Send keep-alive packets are opened a function,This allows client/server sends a packet with a specific over time to the other,Once the timeout,You break,Close links。This avoids linking hangs for a long time causes error。and,Once again an error,A moment will be able to log in again。
In short,One of the two。
Our first server-side modifications:
1 2 3 4 5 6 |
//编辑文件: /etc/ssh/sshd_config //在内容末尾添加如下语句: ClientAliveInterval 60 //保存后重启服务: /etc/init.d/ssh restart |
Such,Has not received from the client when the server for 60 seconds keep-alive,Closes session。
Next is the client changes:
If you do not have server permissions,So this is a good choice--and,This approach also has an advanced method of using--set separately for a server idle time:
1 2 3 4 5 6 7 |
//编辑文件: ~/.ssh/config //在里边添加如下语句: ServerAliveInterval 60 //针对某一服务器的写法: //使用如下选项连接服务器: ssh -o ServerAliveInterval=60 user@sshserver |
Original article written by LogStudio:R0uter's Blog » When SSH encounters "Write failed: Broken pipe”
Reproduced Please keep the source and description link:https://www.logcg.com/archives/897.html