[PR #6020] [CLOSED] feat: add SSH access mode for node management (Phase 1-3) #6057

Closed
opened 2026-11-02 04:06:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6020
Author: @yangbin1322
Created: 7/17/2026
Status: ❌ Closed

Base: main ← Head: feat/ssh-access-mode


📝 Commits (2)

  • 8735f3a feat: add SSH access mode for node management (Phase 1-3)
  • a990101 fix: address PR review for SSH access mode

📊 Changes

38 files changed (+2150 additions, -33 deletions)

View changed files

📝 .env.example (+8 -0)
📝 frontend/public/openapi.json (+172 -0)
📝 frontend/src/api/queries/useNodeMutations.ts (+6 -0)
📝 frontend/src/generated/examples.ts (+17 -0)
📝 frontend/src/generated/schemas.ts (+91 -0)
📝 frontend/src/generated/types.ts (+18 -0)
📝 frontend/src/generated/zod.ts (+19 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+10 -0)
📝 frontend/src/pages/nodes/NodeFormModal.tsx (+213 -4)
📝 frontend/src/pages/nodes/NodesPage.tsx (+2 -1)
📝 frontend/src/schemas/node.ts (+39 -0)
📝 go.sum (+2 -0)
📝 internal/config/config.go (+9 -0)
📝 internal/database/model/model.go (+41 -5)
➕ internal/util/crypto/secret.go (+98 -0)
➕ internal/util/crypto/secret_test.go (+131 -0)
📝 internal/web/controller/node.go (+37 -2)
📝 internal/web/job/node_heartbeat_job.go (+23 -0)
📝 internal/web/service/node.go (+176 -5)
📝 internal/web/service/node_mtls_test.go (+1 -1)

...and 18 more files

📄 Description

Extend node management so the panel can adopt a plain Linux server over SSH, alongside the existing API mode that manages an installed 3x-ui panel. SSH and API are two access modes of one node, not separate systems: the server list and management flow stay unified, and an SSH node is designed to become an API node in place once a panel is installed on it (a later phase).

Why on the Node model rather than a new model: the requirement keeps one unified server list and foresees converting an SSH row into an API-managed node in place, which a split model would need a migration between. model.Node gains a Mode (api|ssh, defaulting to api so every existing row is untouched) plus SSH fields; GORM AutoMigrate adds the columns, no hand-written migration needed.

Credentials must be replayed to the remote host, so unlike a login password they cannot be hashed. SSH password and private key are encrypted at rest with AES-256-GCM under XUI_SECRET_KEY (internal/util/crypto/secret.go), fail-closed if the key is unset, and are write-only over the API (json:"-"). Host-key verification mirrors the existing TlsVerifyMode pattern via SshHostKeyMode (trust|pin|skip) + SshHostKeySha256 rather than blindly accepting any key, so a credential is never handed to a machine-in-the-middle.

Backward compatibility: normalize() branches on mode and keeps API-node validation identical; the heartbeat probes SSH nodes over SSH (reachable/ unreachable) instead of HTTP so they never park at a false "offline" and never feed the panel-only traffic-sync or CPU/memory history.

Adds POST /panel/api/nodes/testSSH, the SSH connect/test service, the React add/edit dialog with an access-mode toggle, i18n keys across all 13 locales, and unit + real-SSH-server integration tests. Verified end to end against a live Ubuntu 22.04 host (password and private-key auth, host-key capture, OS detection, encrypted-at-rest confirmed in the DB).

Summary

Why

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Screenshots / recordings

Breaking changes

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6020 **Author:** [@yangbin1322](https://github.com/yangbin1322) **Created:** 7/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/ssh-access-mode` --- ### 📝 Commits (2) - [`8735f3a`](https://github.com/MHSanaei/3x-ui/commit/8735f3a8377d2a7d8132dc5da4786036d5edabae) feat: add SSH access mode for node management (Phase 1-3) - [`a990101`](https://github.com/MHSanaei/3x-ui/commit/a99010125bc9b6eec49019f2afd1e85b2f7796b4) fix: address PR review for SSH access mode ### 📊 Changes **38 files changed** (+2150 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+8 -0) 📝 `frontend/public/openapi.json` (+172 -0) 📝 `frontend/src/api/queries/useNodeMutations.ts` (+6 -0) 📝 `frontend/src/generated/examples.ts` (+17 -0) 📝 `frontend/src/generated/schemas.ts` (+91 -0) 📝 `frontend/src/generated/types.ts` (+18 -0) 📝 `frontend/src/generated/zod.ts` (+19 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+10 -0) 📝 `frontend/src/pages/nodes/NodeFormModal.tsx` (+213 -4) 📝 `frontend/src/pages/nodes/NodesPage.tsx` (+2 -1) 📝 `frontend/src/schemas/node.ts` (+39 -0) 📝 `go.sum` (+2 -0) 📝 `internal/config/config.go` (+9 -0) 📝 `internal/database/model/model.go` (+41 -5) ➕ `internal/util/crypto/secret.go` (+98 -0) ➕ `internal/util/crypto/secret_test.go` (+131 -0) 📝 `internal/web/controller/node.go` (+37 -2) 📝 `internal/web/job/node_heartbeat_job.go` (+23 -0) 📝 `internal/web/service/node.go` (+176 -5) 📝 `internal/web/service/node_mtls_test.go` (+1 -1) _...and 18 more files_ </details> ### 📄 Description Extend node management so the panel can adopt a plain Linux server over SSH, alongside the existing API mode that manages an installed 3x-ui panel. SSH and API are two access modes of one node, not separate systems: the server list and management flow stay unified, and an SSH node is designed to become an API node in place once a panel is installed on it (a later phase). Why on the Node model rather than a new model: the requirement keeps one unified server list and foresees converting an SSH row into an API-managed node in place, which a split model would need a migration between. model.Node gains a Mode (api|ssh, defaulting to api so every existing row is untouched) plus SSH fields; GORM AutoMigrate adds the columns, no hand-written migration needed. Credentials must be replayed to the remote host, so unlike a login password they cannot be hashed. SSH password and private key are encrypted at rest with AES-256-GCM under XUI_SECRET_KEY (internal/util/crypto/secret.go), fail-closed if the key is unset, and are write-only over the API (json:"-"). Host-key verification mirrors the existing TlsVerifyMode pattern via SshHostKeyMode (trust|pin|skip) + SshHostKeySha256 rather than blindly accepting any key, so a credential is never handed to a machine-in-the-middle. Backward compatibility: normalize() branches on mode and keeps API-node validation identical; the heartbeat probes SSH nodes over SSH (reachable/ unreachable) instead of HTTP so they never park at a false "offline" and never feed the panel-only traffic-sync or CPU/memory history. Adds POST /panel/api/nodes/testSSH, the SSH connect/test service, the React add/edit dialog with an access-mode toggle, i18n keys across all 13 locales, and unit + real-SSH-server integration tests. Verified end to end against a live Ubuntu 22.04 host (password and private-key auth, host-key capture, OS detection, encrypted-at-rest confirmed in the DB). ## Summary <!-- What does this PR do? One or two sentences. --> ## Why <!-- What problem does this solve, or what use case does it enable? Link related issues here: "Closes #123", "Refs #456". --> ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? <!-- Concrete steps the reviewer can repeat. For UI changes: which page, which actions, which browser. For backend: which endpoint, which payload, which response. Mention any new unit/integration tests added. --> ## Screenshots / recordings <!-- Required for UI changes. Drag images or GIFs here. Remove if N/A. --> ## Breaking changes <!-- Does this change require existing users to update their config, run a migration, or change their API calls? If yes, describe the migration path. Write "None" if there are no breaking changes. --> ## Checklist - [ ] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [ ] My commits follow the project's existing message style. - [ ] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6057
No description provided.