我在这样的脚本中有Python代码-
def run_ssh_cmd(host, cmd):
global i
i += 1
ql(f"Running cmd {i}: {cmd}", "info", host)
cmds = ["ssh", "-t", "-p", "22", host, cmd]
process = Popen(cmds, stdout=PIPE, stderr=PIPE, stdin=PIPE)
stdout, stderr = process.communicate()
# Check if the command was successful
if process.returncode != 0:
ql(f"Error occurred on cmd {cmd}: {stderr}", "error", host)
raise CalledProcessError(process.returncode, cmds, stderr)
当我从我的电脑上运行该代码时,每次它都会在第 6 个命令上给出超时错误。错误指出“ssh:连接到主机 sub1.domain.io 端口 22:连接超时”