feat: SSH 改纯密码认证(paramiko,禁用密钥/agent 不弹授权框,密码放 .env)+ 部署配置全迁 .env(config.py 不再内置 STF/SSH/Tailscale 值,.env.example 补全 11 项)
This commit is contained in:
+6
-14
@@ -13,32 +13,24 @@
|
||||
"""
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
|
||||
from config import STF_SSH_TARGET, STF_ADB_CONTAINER, STF_SCRIPT_PATH
|
||||
from config import STF_ADB_CONTAINER, STF_SCRIPT_PATH
|
||||
from core.logger import get_logger
|
||||
from core.ssh_client import run as _ssh_run, SSHError
|
||||
|
||||
_log = get_logger("core.stfdev")
|
||||
|
||||
_SSH_BASE = ["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=5",
|
||||
"-o", "StrictHostKeyChecking=no", STF_SSH_TARGET]
|
||||
|
||||
|
||||
class StfDevError(Exception):
|
||||
"""STF 设备管理错误(SSH/脚本/命令失败)。"""
|
||||
|
||||
|
||||
def _ssh(cmd, timeout=25):
|
||||
"""在 220 上执行一条 shell 命令。返回 (code, stdout, stderr)。"""
|
||||
"""在 220 上执行一条 shell 命令(认证见 core.ssh_client)。返回 (code, stdout, stderr)。"""
|
||||
try:
|
||||
r = subprocess.run(_SSH_BASE + [cmd], capture_output=True, timeout=timeout)
|
||||
except subprocess.TimeoutExpired:
|
||||
raise StfDevError(f"SSH 执行超时: {cmd[:80]}")
|
||||
except Exception as e:
|
||||
raise StfDevError(f"SSH 连接失败: {e}")
|
||||
out = (r.stdout or b"").decode("utf-8", errors="replace")
|
||||
err = (r.stderr or b"").decode("utf-8", errors="replace")
|
||||
return r.returncode, out, err
|
||||
return _ssh_run(cmd, timeout=timeout)
|
||||
except SSHError as e:
|
||||
raise StfDevError(str(e))
|
||||
|
||||
|
||||
def _adb(args, remote_timeout=15):
|
||||
|
||||
Reference in New Issue
Block a user