Documentation
¶
Overview ¶
Package sshconf generates the OpenSSH client configuration that points an editor (VSCodium Remote-SSH) or the ssh CLI at a devc workspace. The Host block uses a ProxyCommand that runs `devc ssh --stdio`, so no port is published and no TCP listener exists; forwardPorts become LocalForward lines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureInclude ¶
EnsureInclude guarantees that userSSHConfig (usually ~/.ssh/config) begins with `Include <includePath>`, adding it idempotently. On the first insertion it writes a timestamped backup of the existing file. It returns whether a change was made.
The Include is placed at the very top because OpenSSH applies the first matching option for a keyword, so devc's per-workspace options take precedence over any later global defaults.
func RemoveWorkspaceConfig ¶
RemoveWorkspaceConfig deletes a workspace's generated config file (used by `devc down --purge`). Absence is not an error.
func Render ¶
Render returns the Host block for a workspace. It is deterministic so the generated file is stable across `devc up` runs (no spurious diffs).
func WriteWorkspaceConfig ¶
WriteWorkspaceConfig writes the generated Host block(s) to path (0644), creating parent directories. The file is fully owned by devc and rewritten each time.
Types ¶
type Params ¶
type Params struct {
// Alias is the ssh Host name, e.g. "devc.shop".
Alias string
// User is the login user reported to ssh (informational; the agent decides
// the real session user). Defaults to "root".
User string
// DevcBin is the absolute path to the devc binary used in ProxyCommand.
DevcBin string
// ConfigPath is the absolute path to the workspace's devcontainer.json. It is
// baked into the ProxyCommand as `--config` so resolution never depends on the
// caller's working directory - VSCodium spawns the ProxyCommand from its own
// cwd, where a bare `devc ssh` would find no devcontainer.json and exit.
ConfigPath string
// RuntimePath is the absolute path to the container runtime (podman/docker).
// Baked into the ProxyCommand as `--runtime` so the transport does not depend
// on PATH - GUI-launched editors spawn the ProxyCommand with a stripped
// environment where a PATH lookup for podman/docker can fail. Empty omits it.
RuntimePath string
// WorkspaceName is passed to `devc ssh --stdio <name>` (the slug).
WorkspaceName string
// IdentityFile, KnownHostsFile point at the workspace's key material.
IdentityFile string
KnownHostsFile string
// ControlDir holds the multiplexing socket (ControlPath). Usually the
// workspace state dir.
ControlDir string
// Forwards are host->container port forwards rendered as LocalForward.
Forwards []Forward
// ForwardAgent renders `ForwardAgent yes` so the client forwards its
// ssh-agent into the container (the agent must also allow it). Off by default.
ForwardAgent bool
}
Params are the inputs to a generated Host block.