sshconfig

package
v0.36.0-next.internal.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sshconfig manages the SSH client configuration for `vcluster platform connect slurm`. It maintains a dedicated, fully managed drop-in file (~/.ssh/vcluster/config) with one marker-delimited Host block per Slurm instance, and idempotently wires it into the user's main ~/.ssh/config via a single `Include` line. The Include is placed near the top but is careful never to split a leading comment block from the lines it documents (see includeInsertIndex). It never edits any other part of the main config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultAlias

func DefaultAlias(instance, project string) string

DefaultAlias returns the default alias for an instance: <instance>.<project>.slurm.

func NormalizeHost

func NormalizeHost(host string) string

NormalizeHost strips the scheme and any trailing slash so the marker stays a single clean token.

Types

type Block

type Block struct {
	// PlatformHost, Project and Instance form the block's source identity and
	// are encoded into the BEGIN/END markers. PlatformHost is also pinned into
	// the generated ProxyCommand (--host) so the alias keeps targeting the same
	// platform even after the CLI logs into a different one.
	PlatformHost string
	Project      string
	Instance     string
	// Alias is the SSH host alias the user types (`ssh <alias>`).
	Alias string
	// Executable is the absolute path to the vcluster binary used in the
	// ProxyCommand.
	Executable string
	// Insecure adds --insecure to the generated ProxyCommand so future ssh
	// sessions tolerate the platform's self-signed certificate.
	Insecure bool
}

Block describes a single managed Host block.

type Manager

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

Manager reads and writes the managed SSH configuration.

func New

func New() (*Manager, error)

New returns a Manager rooted at the current user's ~/.ssh directory.

func NewWithDir

func NewWithDir(dir string) *Manager

NewWithDir returns a Manager rooted at an explicit directory. It is intended for tests; generated config text uses absolute paths under dir.

func (*Manager) Add

func (m *Manager) Add(b Block) error

Add writes or replaces the managed block for b and ensures the main config includes the managed file. It is idempotent: re-running with the same inputs produces no change. An alias already used by a differently-sourced block is a collision and returns an error suggesting --alias.

func (*Manager) List

func (m *Manager) List() ([]string, error)

List returns the aliases of all managed blocks.

func (*Manager) Remove

func (m *Manager) Remove(platformHost, project, instance string) (bool, error)

Remove deletes the managed block identified by platformHost/project/instance and cleans up its known_hosts entries. It reports whether a block was removed.

Jump to

Keyboard shortcuts

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