feat: SSH terminal - the agent connects by SSH to another host (password, key file or its own keys) and the shell opens in a tab with the connection's progress shown; host keys trusted on first use, a changed one refused

This commit is contained in:
redtea committed 2026-10-14 21:20:18 +03:00
1 parent 5a204ae9bb
commit 5a4dc596d5
7 files changed
+515 -21

No files matched your search

+33 -5
View File
@@ -18,8 +18,23 @@ const (
CtrlOpenForward = "open_forward"
// CtrlTask tells the agent to fetch and run the one-shot task TaskID.
CtrlTask = "task"
// CtrlOpenSSH tells the agent to open an SSH connection to SSH and bridge
// its shell to the session id, as a terminal.
CtrlOpenSSH = "open_ssh"
)
// SSHTarget is where an SSH terminal connects and how it signs in: a
// password, a private key (PEM or OpenSSH, with its passphrase if it has
// one), or, with neither, the agent user's own keys in ~/.ssh.
type SSHTarget struct {
Host string `json:"host"`
Port int `json:"port,omitempty"`
User string `json:"user"`
Password string `json:"password,omitempty"`
Key string `json:"key,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
}
// EnrollRequest is sent once by a freshly installed agent.
type EnrollRequest struct {
Name string `json:"name"`
@@ -38,11 +53,12 @@ type EnrollResponse struct {
// ControlMessage is the body returned by the control long-poll.
type ControlMessage struct {
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
Port int `json:"port,omitempty"` // CtrlOpenForward: client-side port to dial
TaskID string `json:"task_id,omitempty"` // CtrlTask
User string `json:"user,omitempty"` // CtrlOpenTerminal: OS user for the shell ("" = the agent's own)
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
Port int `json:"port,omitempty"` // CtrlOpenForward: client-side port to dial
TaskID string `json:"task_id,omitempty"` // CtrlTask
User string `json:"user,omitempty"` // CtrlOpenTerminal: OS user for the shell ("" = the agent's own)
SSH *SSHTarget `json:"ssh,omitempty"` // CtrlOpenSSH
}
// Transports an agent can reach the server by.
@@ -96,8 +112,20 @@ type InBatch struct {
type OutMessage struct {
Data string `json:"data,omitempty"` // base64 bytes
Exit bool `json:"exit,omitempty"`
// Status tells the panel how an SSH terminal's connection goes: one of
// the SSHStatus values, with Note to show.
Status string `json:"status,omitempty"`
Note string `json:"note,omitempty"`
}
// The steps of an SSH terminal's connection, as OutMessage.Status.
const (
SSHDial = "dial" // connecting to the host
SSHAuth = "auth" // the host answered, signing in
SSHOK = "ok" // signed in, the shell runs
SSHErr = "err" // it failed; Note says why
)
// --- one-shot tasks (file manager, native in the agent) ---
const (