摘要:我使用Mac计算机作为构建和测试自动化的代理。从EC2实例(ssh客户端)到Mac(ssh服务器)需要长期运行的SSH连接。这些连接以随机间隔(无论负载如何)下降,并显示错误消息:
packet_write_wait: Connection to [My Macs IP] port 22: Broken pipe
这只会在Mac10.14和10.13上发生,而在Mac10.12或Linux上则不会发生。
到目前为止已尝试:正如许多帖子所建议的,我已经更改了一些ssh配置:
服务器(mac)上的/ private / etc / ssh / sshd_config
ClientAliveInterval 30
ClientAliveMaxCount 1200
TCPKeepAlive no
/ client(linux ec2)上的/ etc / ssh / ssh_config
Host *
ServerAliveInterval 30
ServerAliveMaxCount 1200
TCPKeepAlive no
IPQoS lowdelay throughput
我正在使用此命令运行这些测试(可在Cloudbees支持文章https://support.cloudbees.com/hc/en-us/articles/115001369667-dedicated-SSH-agents-formerly-slaves-get-disconnected中找到)
ssh -vvv user@agent_ip "bash -c 'while true ; do export sleeptime=$(( 10 )) ; echo "Hey, time is '$(date)'. Now sleeping for \$sleeptime seconds" ; sleep \$sleeptime ; done'"
我希望这些连接可以无限期地存活,就像在ec2和linux或Mac10.12之间一样。我在超级详细模式(-vvv标志)下进行了测试,并在断开连接时捕获了一些有趣的日志:
debug1: client_input_channel_req: channel 0 rtype keepalive@openssh.com reply 1
debug3: send_packet: type 100
Hey, time is Wed May 22 21:06:45 PDT 2019. Now sleeping for 10 seconds
Hey, time is Wed May 22 21:06:55 PDT 2019. Now sleeping for 10 seconds
Hey, time is Wed May 22 21:07:05 PDT 2019. Now sleeping for 10 seconds
debug3: receive packet: type 98
debug1: client_input_channel_req: channel 0 rtype keepalive@openssh.com reply 1
debug3: send packet: type 100
Hey, time is Wed May 22 21:07:15 PDT 2019. Now sleeping for 10 seconds
debug3: send packet: type 80
debug3: send packet: type 80
Hey, time is Wed May 22 21:07:25 PDT 2019. Now sleeping for 10 seconds
debug3: send packet: type 1
packet_write_wait: Connection to 10.###### port 22: Broken pipe