agent

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package agent implements the in-container SSH server that devc injects and runs over `podman exec -i ... /.devc/agent __serve`. The transport is stdin/ stdout - there is no TCP listener and no published port - but the SSH crypto still runs so a real client (VSCodium Remote-SSH, OpenSSH) connects normally.

The server accepts a single connection (the one exec pipe it was started for) and serves every channel the client opens on it: interactive/exec sessions with optional PTY, and direct-tcpip forwards (how the editor reaches its own server port and how `ssh -L` works).

Index

Constants

This section is empty.

Variables

View Source
var SFTPCommand = []string{"__sftp"}

SFTPCommand is the argv the agent re-execs to serve SFTP as the session user. The main devc binary implements it (running an in-process SFTP server over stdin/stdout); the agent only spawns it with dropped privileges. It is a var so tests can point it at a stub.

Functions

This section is empty.

Types

type Config

type Config struct {
	// HostKey is the server's host key (from /.devc/host_key).
	HostKey ssh.Signer
	// Authorized is the set of public keys allowed to connect (the workspace's
	// single client key).
	Authorized []ssh.PublicKey
	// User is the OS user sessions run as (remoteUser); empty = the agent's own uid.
	User string
	// Cwd is the working directory for sessions (containerWorkspaceFolder).
	Cwd string
	// Environment is injected into every session (remoteEnv + probed env).
	Environment map[string]string
	// AgentForwarding allows ssh-agent forwarding: when the client requests it
	// (auth-agent-req@openssh.com), the server exposes a proxy SSH_AUTH_SOCK that
	// tunnels signing requests back to the client's agent. Off by default.
	AgentForwarding bool
}

Config configures a Server. All fields are required except Environment.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server serves one SSH connection over a byte stream.

func NewServer

func NewServer(cfg Config) (*Server, error)

NewServer validates cfg and returns a Server.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer) error

Serve runs the SSH server over the given stream until the client disconnects or ctx is cancelled. Pass stdin as r and stdout as w in the __serve command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL