"""Remove broken backup file from sites-enabled, keep only clean gfil""" import paramiko JD_HOST = "111.228.37.165" JD_USER = "root" JD_PASS = "Liudecai110" LAB_HOST = "216.144.233.14" LAB_USER = "root" LAB_PASS = "Kt9V72Tx2c48ChikKU" jd = paramiko.SSHClient() jd.set_missing_host_key_policy(paramiko.AutoAddPolicy()) jd.connect(JD_HOST, port=22, username=JD_USER, password=JD_PASS, timeout=20, banner_timeout=60, allow_agent=False, look_for_keys=False) cmd = f"""sshpass -p '{LAB_PASS}' ssh -o StrictHostKeyChecking=no {LAB_USER}@{LAB_HOST} ' # Remove the broken backup from sites-enabled (nginx loads ALL files in this dir) rm -f /etc/nginx/sites-enabled/gfil.bak.broken # Verify only clean files remain echo "=== sites-enabled contents ===" ls -la /etc/nginx/sites-enabled/ # Show current gfil config echo "=== Current gfil config ===" cat /etc/nginx/sites-enabled/gfil # Test nginx -t 2>&1 if [ $? -eq 0 ]; then systemctl reload nginx echo "SUCCESS: Nginx restored and reloaded" else echo "FAILED" fi # Final check - site responding curl -s -o /dev/null -w "HTTP status" http://localhost/ 2>/dev/null '""" stdin, stdout, stderr = jd.exec_command(cmd, timeout=30) print(stdout.read().decode()) jd.close()