# -*- coding: utf-8 -*- import paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False) cmds = [ "systemctl start douyinweb-api douyinweb-web; sleep 4; systemctl is-active douyinweb-api douyinweb-web", "curl -sI 'http://127.0.0.1:8014/api/sessions/93680996-cafa-430b-8951-842624b46230/cover'", ] for cmd in cmds: print("$", cmd) stdin, stdout, stderr = c.exec_command(cmd, timeout=40) print(stdout.read().decode("utf-8", "replace")) err = stderr.read().decode("utf-8", "replace") if err.strip(): print(err) c.close()