修复:向导认证成功后卡死、配置不持久化
根因:非 Windows 走 keyring 加密,无桌面环境的服务器上 keyring 后端不可用, 保存时抛异常/挂起 → 第2步不出现且配置未落盘。 - storage: 非 Windows 改为明文保存 + 文件权限 600(与 ~/.ssh 私钥同级),不再依赖 keyring - cli: 顶层异常兜底(打印堆栈,不再无声退出);向导显示配置文件路径 - 兼容读取旧 kr: 前缀配置;install.sh 去掉 keyring 依赖
This commit is contained in:
@@ -112,7 +112,7 @@ def cmd_tunnel_add(store, args) -> int:
|
||||
|
||||
def cmd_list(store, _args) -> int:
|
||||
if store.warn_plaintext:
|
||||
_print("提示: 当前平台无可用密钥后端,密码以明文保存于配置文件。")
|
||||
_print("提示: 当前平台密码以明文保存于配置文件(权限已设为仅本用户可读)。")
|
||||
_print("主机:")
|
||||
if not store.data["hosts"]:
|
||||
_print(" (无) 添加: ssh-tunnel host add <名称> user@host")
|
||||
@@ -171,7 +171,7 @@ def run_foreground(store: Store, chosen: list) -> int:
|
||||
mgr.apply_config(chosen, hosts_by_id)
|
||||
|
||||
if store.warn_plaintext:
|
||||
_print("提示: 当前平台无可用密钥后端,密码以明文保存于配置文件。")
|
||||
_print("提示: 当前平台密码以明文保存于配置文件(权限已设为仅本用户可读)。")
|
||||
names = ", ".join(t["name"] for t in chosen)
|
||||
_print(f"启动隧道: {names} — Ctrl+C 退出")
|
||||
|
||||
@@ -376,9 +376,10 @@ def wizard(store: Store) -> int:
|
||||
_print("│ SSH 隧道配置向导 │")
|
||||
_print("╰─────────────────────────────╯")
|
||||
_print("按中文提示输入,直接回车采用 [方括号] 里的默认值;Ctrl+C 随时退出。")
|
||||
_print(f"配置文件: {store.path}")
|
||||
|
||||
if store.warn_plaintext:
|
||||
_print("提示: 当前平台无可用密钥后端,密码将以明文保存于配置文件。")
|
||||
_print("提示: 当前平台密码以明文保存于配置文件(权限已设为仅本用户可读)。")
|
||||
|
||||
host = _wizard_pick_host(store)
|
||||
if not host:
|
||||
@@ -458,4 +459,13 @@ def main() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
try:
|
||||
sys.exit(main())
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(130)
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception: # noqa: BLE001 出错必须可见,禁止无声退出
|
||||
import traceback
|
||||
sys.stderr.write("\n发生错误,已退出:\n" + traceback.format_exc())
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user