Add multi-host terminal: NAS + VPS side-by-side
Deploy Dashboard / deploy (push) Failing after 3m5s

This commit is contained in:
Gan, Jimmy
2026-02-20 00:53:29 +08:00
parent 6047b2aade
commit 050793e0f0
6 changed files with 107 additions and 56 deletions
+9 -3
View File
@@ -5,8 +5,13 @@ import asyncssh
import jwt
import config
HOSTS = {
"nas": {"host": config.SSH_HOST, "user": config.SSH_USER, "key": config.SSH_KEY_PATH},
"vps": {"host": config.VPS_SSH_HOST, "user": config.VPS_SSH_USER, "key": config.VPS_SSH_KEY_PATH},
}
async def ws_endpoint(websocket: WebSocket, token: str = Query("")):
async def ws_endpoint(websocket: WebSocket, token: str = Query(""), host: str = Query("nas")):
try:
payload = jwt.decode(token, config.SECRET_KEY, algorithms=[config.ALGORITHM])
if payload.get("sub") != config.ADMIN_USER:
@@ -18,10 +23,11 @@ async def ws_endpoint(websocket: WebSocket, token: str = Query("")):
await websocket.accept()
h = HOSTS.get(host, HOSTS["nas"])
try:
conn = await asyncssh.connect(
config.SSH_HOST, username=config.SSH_USER,
client_keys=[config.SSH_KEY_PATH], known_hosts=None,
h["host"], username=h["user"],
client_keys=[h["key"]], known_hosts=None,
)
except Exception:
await websocket.close(code=1011, reason="SSH connection failed")