Documentation
¶
Overview ¶
Package server provides the CLI for dcx-agent, a minimal binary that runs inside containers and exposes an SSH surface for host-side dcx.
Package server — the netgate enforces which source IPs may complete an SSH handshake. It is wired into gliderlabs/ssh's ConnCallback, which runs before any SSH bytes are exchanged. A nil return from the callback closes the connection.
The gate is the load-bearing pre-handshake filter. Even though Docker's -p <bind>:<host>:<container> restricts which host interface accepts packets, the agent may bind 0.0.0.0 inside the container (WSL2 NAT) — in that case the gate is the only layer enforcing "loopback-only by default."
Package server implements the TCP SSH server that runs inside dcx-managed containers. It is bundled into the `dcx-agent` binary and invoked as `dcx-agent listen`.
All client connections complete public-key authentication against a mounted authorized_keys file. A pre-handshake IP gate rejects any source address outside the configured allowlist (loopback by default).
Index ¶
Constants ¶
const DefaultReadyFilePath = "/var/lib/dcx/agent-ready"
DefaultReadyFilePath is the sentinel the agent writes once Accept is live inside the container. Readable from the host via `docker exec cat`.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶ added in v0.7.0
type Config struct {
User string
Shell string
WorkDir string
HostKeyPath string
// Paths (in order) to check for authorized pubkeys. First match wins.
// Typically [DCXSecretPath("authorized_keys"),
// filepath.Join(userHome, ".ssh", "authorized_keys")].
AuthorizedKeysPaths []string
// Pre-handshake loopback gate. A non-loopback remote address has its
// connection closed before any SSH bytes are exchanged.
Gate *Gate
// Path to write the ready sentinel once Accept is live. Empty means skip
// the sentinel (useful for tests). In production this points at
// /var/lib/dcx/agent-ready inside the container, readable via
// `docker exec cat`.
ReadyFile string
}
Config holds everything required to build a Server.
type Gate ¶ added in v0.7.0
type Gate struct {
// contains filtered or unexported fields
}
Gate is an IP allowlist. It answers the question: should this source address be allowed through the handshake?
func FromCIDRs ¶ added in v0.7.0
FromCIDRs parses a list of CIDR strings (or bare IPs, which are treated as /32 or /128) into a Gate. Returns an error if any entry is malformed.
An empty list returns a Gate that rejects all connections. Callers that want "loopback-only" should either combine with Loopback or include "127.0.0.0/8" and "::1/128" explicitly.
func Loopback ¶ added in v0.7.0
func Loopback() *Gate
Loopback returns a Gate that permits only 127.0.0.0/8 and ::1/128.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the SSH server.
type ShellConfig ¶
type ShellConfig struct {
// Args to add when starting an interactive shell (replaces default -l)
Args []string
// Env vars to set
Env []string
}
ShellConfig contains shell-specific configuration for integration.
func SetupShellIntegration ¶
func SetupShellIntegration(shell string) ShellConfig
SetupShellIntegration creates integration files and returns shell configuration. This enables terminal title updates showing the typed command (like Kitty/Ghostty).