Net-ssh session timeout

送分小仙女□ 提交于 2020-01-04 06:45:10

问题


I am using Net-sshto launch a remote Python script. The Ruby script seems to hang and never complete when the Python script takes a long time to execute (around 20 minutes).

I have tested the script by running it directly and it completes without any error. Also everything works fine when the script is executed in a shorter amount of time.

This is an extract of the code I am using:

(0..(@number_of_vms - 1)).each_with_index do |vm, i|
  threads << Thread.new do
    Net::SSH.start('ip-address-vm', user, options = ...) do |session|
      cmd = 'python python_script.py'
      output = session.exec!(cmd)
    end
  end
end
threads.each {|thr| thr.join }

Could this be related to some kind of timeout for the ssh session?

EDIT: I have verified that the script is completed successfully on the remote server.


回答1:


The problem was associated to the SSH server time out. I solved the problem by changing the settings on the server. I have added the following line:

ClientAliveInterval 60

in /etc/ssh/sshd_config

Based on this article it should be possible to make a similar modification on the client:

ServerAliveInterval 60

in /etc/ssh/ssh_config



来源:https://stackoverflow.com/questions/34865492/net-ssh-session-timeout

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!