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 ¶
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").
Types ¶
This section is empty.