import paramiko, time ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("47.108.78.12", port=22, username="root", password="10102442Lb!", timeout=10) s_in, s_out, s_err = ssh.exec_command("chmod +x /opt/smail/smail_new && pkill -9 -f smail || true") s_out.channel.recv_exit_status() time.sleep(1) s_in, s_out, s_err = ssh.exec_command("cp /opt/smail/smail /opt/smail/smail.bak_0914 && cp /opt/smail/smail_new /opt/smail/smail && chmod +x /opt/smail/smail") s_out.channel.recv_exit_status() ssh.exec_command("cd /opt/smail && nohup ./run.sh > /dev/null 2>&1 &") time.sleep(3) s_in, s_out, s_err = ssh.exec_command("ps aux | grep smail && tail -n 20 /opt/smail/log/stdout.log") print(s_out.read().decode()) ssh.close()