Capistrano部署因SSH报错失败:消息过长与文件描述符问题
部署CentOS服务器时Capistrano执行restorecon步骤遇SSH多路复用错误
环境信息
- 服务器系统:CentOS
- SSHD版本:
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017(无法升级或从源码编译) - SSHD关键配置:
TCPKeepAlive yes UseDns no Protocol 2
问题现象
使用Capistrano将项目部署到5台服务器时,多数步骤可正常执行,但在执行restorecon步骤(具体命令:/usr/sbin/restorecon -R /u/apps/my_app/releases/20230724100000)时出现以下错误:
mm_receive_fd: recvmsg: Message too long mux_master_process_stdio_fwd: failed to receive fd 0 from client mux_client_request_stdio_fwd: read from master failed: Broken pipe channel_post_mux_listener: accept: Too many open files muxclient: master hello exchange failed mm_receive_fd: recvmsg: Message too long mux_master_process_stdio_fwd: failed to receive fd 0 from client mux_client_request_stdio_fwd: read from master failed: Broken pipe
错误根源提示:
Caused by: Net::SSH::Proxy::ConnectError: command failed: ssh rorra@bastion.mydomain.com -o ConnectTimeout=60 -o ControlMaster=auto -o ControlPath=/tmp/sshrorra@bastion.mydomain.com -W server01.mydomain.com:\22
已尝试的无效操作
- 移除
ControlMaster配置,问题未解决 - 将
ControlMaster设为none,导致Capistrano每一步都要求输入凭据,操作耗时过长且命令繁琐 - 执行命令
sudo systemctl restart sshd.service重启SSHD服务,问题依旧存在
内容的提问来源于stack exchange,提问作者rorra
相关产品推荐
相关产品推荐

