client = paramiko.SSHClient()
client.connect(<host details...>)
try:
stdin, stdout, stderr = client.exec_command(cmd, timeout=timeout)
err = stderr.channel.recv_stderr(sys.maxsize)
exit_code = stdout.channel.recv_exit_status()
except socket.timeout:
# Need to kill all descendants of the exec_command process
我试图在命令之前添加 bash 超时,但是有一些带有';'的链接命令
需要运行 exec_command with get_pty=True,那么什么时候做 client.close() 它也会杀死所有的孩子