ssh

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: GPL-3.0, LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ssh handles SSH key injection and host key collection for node containers, and the export of the SSH client configuration.

Index

Constants

View Source
const InjectKeyScript = `mkdir -p /root/.ssh
printf '%s\n' "$1" >> ` + authorizedKeysPath + `
ssh-keyscan -t ed25519 localhost`

InjectKeyScript appends $1, a public key, to root's authorized_keys, creating the directory if needed, and prints the ed25519 host key that sshd serves, as ssh-keyscan reports it: "localhost ssh-ed25519 AAAA...". It has one command per line, for sh -e, which stops at the first that fails, and takes the key as an argument of the shell, not as part of its script. ssh-keyscan asks sshd, which must be running, for the key it serves; HostKey reads it from the output.

Variables

This section is empty.

Functions

func ExportConfig

func ExportConfig(ctx context.Context, client *docker.Client, fs afero.Fs, dir, realm string, sshContainer docker.ContainerName) error

ExportConfig exports SSH configuration to the given directory by reading the private key and known_hosts from the SSH relay container, in one docker exec, and writing ssh_config, id_ed25519, and known_hosts to dir. When the relay container does not exist, the error satisfies docker.IsNotFound and dir is left as it is.

func GenerateSSHConfig

func GenerateSSHConfig(sshContainer docker.ContainerName, dir, realm string, hosts []string) string

GenerateSSHConfig returns the SSH config that lets the user's ssh reach the realm's nodes through its SSH relay container, with the private key and known_hosts in dir. hosts are the nodes' DNS names; a name in it that is not a node's DNS name in the realm, <node>.<cluster>.<realm>.sind, is left out. For the default realm, it includes hostname canonicalization directives that enable short-name SSH access (e.g. "ssh controller").

func HostKey added in v0.11.0

func HostKey(stdout string) (string, error)

HostKey returns the ed25519 host public key in the output of InjectKeyScript, in "ssh-ed25519 AAAA..." format (without the hostname prefix). It skips ssh-keyscan's comment lines.

Types

This section is empty.

Jump to

Keyboard shortcuts

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