import os
import json
import paramiko
import requests
from datetime import datetime, timedelta
# 从环境变量中读取 ACCOUNTS_JSON
#accounts_json = os.getenv('SERV00_ACCOUNTS')
#accounts = json.loads(accounts_json)
# 可以写死
accounts = [
{ "username": "xxx", "password": "12345678", "panelnum": "10", "host": "s10.serv00.com" },
{ "username": "vs33", "password": "12345678", "panelnum": "0", "host": "s0.serv00.com" },
]
# 尝试通过SSH连接的函数
def ssh_connect(host, username, password, bark):
transport = None
now_beijing = (datetime.utcnow() + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') # 北京时间东8区
try:
transport = paramiko.Transport((host, 22))
transport.connect(username=username, password=password)
ssh_status = "SSH连接成功"
print(f"{username} SSH连接成功。")
except Exception as e:
_status = f"SSH连接失败,错误信息: {e}"
print(f"SSH连接失败: {e}")
finally:
if transport is not None:
transport.close()
# 循环执行任务
for account in accounts:
ssh_connect(account['host'], account['username'], account['password'])
6 个赞
这是保号还是保活?现在serv00不需要保号了,你这也没有去保活指定进程 ![]()
2 个赞
应该是保号, 我改下 ![]()
真的假的?
感谢大佬!
现在不需要ssh保号了,只需要搞定进程保活就好
serv00老是把我的crontab任务删掉 ![]()
此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。