Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// ListenAddr is the address the SSH server listens on. It must be a
// loopback address unless AllowNonLoopback is set.
ListenAddr string
// HostKeyPath is where the ed25519 host key is persisted. It should be on
// storage that survives a container restart, otherwise the fingerprint
// changes every time and clients learn to disable host-key checking.
HostKeyPath string
// IdleTimeout closes a connection after this long without I/O in either
// direction. Zero disables it, which is not advisable: it is the only
// backstop for a connection that never tears down cleanly. Expiry cancels
// the session context, which is what terminates the session's processes.
IdleTimeout time.Duration
// MaxSessions caps concurrent shell and exec channels. Zero or negative
// disables the cap.
//
// The cap covers shell and exec channels only. SFTP subsystems and port
// forwards do not claim a slot, so concurrent transfers and forwarded
// connections are unbounded. That is acceptable for a single-tenant
// workspace pod but is worth knowing before relying on the number.
MaxSessions int
// LoginShell runs the session shell with -l, so it reads the user's login
// profile.
LoginShell bool
// AllowNonLoopback lifts the loopback restriction on ListenAddr. Only set
// it when an authentication layer equivalent to the ingress is provably in
// front of the server.
AllowNonLoopback bool
}
Config holds the SSH server configuration.
func LoadConfig ¶
func LoadConfig() *Config
LoadConfig reads the SSH server configuration from the environment.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the SSH server that terminates remote IDE sessions. It runs inside the workspace container and listens on loopback, where the proxy sidecar reaches it over the pod's shared network namespace.
func New ¶
New validates the configuration and builds the SSH server.
No authentication handler is registered, so gliderlabs accepts every client. That is deliberate: the ingress validates a short-lived token before any byte reaches the proxy, and the loopback bind that Config.validate enforces is what keeps the socket unreachable from outside the pod.
func (*Server) ListenAndServe ¶
ListenAndServe starts the SSH server and blocks until it stops, returning ssh.ErrServerClosed after a Shutdown.
func (*Server) Shutdown ¶
Shutdown closes the listener and drains active connections until ctx expires, then severs whatever is left.
Draining matters on a pod rollout: an abrupt close would cut a session mid-command or mid-SFTP write, which can leave a truncated file. The fallback matters just as much, because the underlying Shutdown waits indefinitely when its context has no deadline, so one lingering session would otherwise hold termination open until the kubelet sends SIGKILL.