#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") PASS = "4669805" c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("107.173.30.245", 4014, "eric", PASS, timeout=60, banner_timeout=120, allow_agent=False, look_for_keys=False) _, o, e = c.exec_command( f""" echo '{PASS}' | sudo -S -p '' bash -c ' docker ps -a --filter name=douyinweb-neko --format "table {{{{.Names}}}}\\t{{{{.Status}}}}\\t{{{{.Ports}}}}" echo ---logs--- docker logs --tail 40 douyinweb-neko-1 2>&1 echo ---local--- curl -sS -m 5 -o /dev/null -w "local9200=%{{http_code}}\\n" http://127.0.0.1:9200/ || true curl -sS -m 5 -o /dev/null -w "wg9200=%{{http_code}}\\n" http://10.9.0.2:9200/ || true ss -lntp | grep 9200 || true ' """, timeout=60, ) print((o.read() + e.read()).decode()) c.close()