New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh 总是自动断掉,几分钟不操作 #2348

Open
HaAlan opened this Issue Jan 15, 2019 · 6 comments

Comments

Projects
None yet
5 participants
@HaAlan
Copy link

HaAlan commented Jan 15, 2019

[简述你的问题]
ssh总是自动断开,不知道是什么问题。是用docker安装的。

使用版本

1.4.6-2
docker 一键安装

问题复现步骤
  1. 登入跳板机,选择id登入,但是总是不能正确匹配到id所对应的主机。
  2. ssh回话连接,不操作大概几分钟就会自动断掉,(跳板机/ssh都会断)
具体表现[截图可能会更好些,最好能截全]
其他

[注:] 完成后请关闭 issue

@HaAlan

This comment has been minimized.

Copy link
Author

HaAlan commented Jan 15, 2019

image

@wojiushixiaobai

This comment has been minimized.

Copy link
Collaborator

wojiushixiaobai commented Jan 16, 2019

@HaAlan 第一个问题请更新代码,如果是docker部署请更新latest镜像
第二个问题请检查资产是否有设置ssh超时退出,jumpserver的默认超时退出为30分钟,可以在web自定义

@HaAlan

This comment has been minimized.

Copy link
Author

HaAlan commented Jan 16, 2019

@wojiushixiaobai 资产没有ssh超时设置,就是升级了jumpserver才出现的这样的情况,web页面也改成2小时才断开了,都还是会出现。

@chenlin0802

This comment has been minimized.

Copy link

chenlin0802 commented Jan 18, 2019

我这边也遇到了这种情况, coco日志 如下:
2019-01-18 02:19:44 [models ERROR] Send to client error: Socket is closed
2019-01-18 08:37:16 [models ERROR] Send to client error: Socket is closed
2019-01-18 08:58:07 [models ERROR] Send to client error: Socket is closed
2019-01-18 09:07:37 [sshd WARNING] Handle connection EOF Error:
2019-01-18 09:32:03 [models ERROR] Send to client error: Socket is closed
2019-01-18 09:41:16 [models ERROR] report_device_attributes() takes from 1 to 2 positional arguments but 4 were given
Traceback (most recent call last):
File "/opt/coco/coco/models.py", line 326, in send
self.s_parse_input_output_filter(data)
File "/opt/coco/coco/models.py", line 231, in s_parse_input_output_filter
self._input = self._parse_input()
File "/opt/coco/coco/models.py", line 356, in _parse_input
return self._cmd_parser.parse_input(self.input_data)
File "/opt/coco/coco/utils.py", line 139, in parse_input
self.stream.feed(d)
File "/opt/py3/lib64/python3.6/site-packages/pyte/streams.py", line 395, in feed
super(ByteStream, self).feed(data)
File "/opt/py3/lib64/python3.6/site-packages/pyte/streams.py", line 196, in feed
taking_plain_text = send(data[offset:offset + 1])
File "/opt/py3/lib64/python3.6/site-packages/pyte/streams.py", line 326, in _parser_fsm
csi_dispatchchar
TypeError: report_device_attributes() takes from 1 to 2 positional arguments but 4 were given
2019-01-18 09:41:16 [models ERROR]
Traceback (most recent call last):
File "/opt/coco/coco/models.py", line 326, in send
self.s_parse_input_output_filter(data)
File "/opt/coco/coco/models.py", line 234, in s_parse_input_output_filter
self._output = self._parse_output()
File "/opt/coco/coco/models.py", line 351, in _parse_output
return self._cmd_parser.parse_output(self.output_data)
File "/opt/coco/coco/utils.py", line 120, in parse_output
self.stream.feed(d)
File "/opt/py3/lib64/python3.6/site-packages/pyte/streams.py", line 395, in feed
super(ByteStream, self).feed(data)
File "/opt/py3/lib64/python3.6/site-packages/pyte/streams.py", line 196, in feed
taking_plain_text = send(data[offset:offset + 1])
StopIteration

@gotofuck

This comment has been minimized.

Copy link

gotofuck commented Feb 1, 2019

也有同样的情况

@xuboatom

This comment has been minimized.

Copy link

xuboatom commented Feb 15, 2019

版本1.4.7也出现操作几分钟就是卡着不动的情况,应该是因为网络不稳定导致ssh卡死不能操作。
建议:在代码中加入ssh的一些心跳设置参数
ExitOnForwardFailure=yes
TCPKeepAlive=yes
ServerAliveInterval=30
ServerAliveCountMax=3

解决方法:
修改 coco/coco/connection.py
72 行 transport.set_keepalive(300) 参数为transport.set_keepalive(20)
如果使用了网关机器跳转
那么在
136行sock = ssh.get_transport().open_channel( 前加两行
transport = ssh.get_transport()
transport.set_keepalive(20)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment