config

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Overview

Package config provide the ssh_config(5) parser and getter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config contains mapping of host's patterns and its options from SSH configuration file.

func Load

func Load(file string) (cfg *Config, err error)

Load SSH configuration from file.

func (*Config) Get

func (cfg *Config) Get(s string) (section *Section)

Get the Host or Match configuration that match with the pattern "s".

func (*Config) Prepend

func (cfg *Config) Prepend(other *Config)

Prepend other Config's sections to this Config. The other's sections will be at the top of the list.

This function can be useful if we want to load another SSH config file without using Include directive.

type PermittedCNAMEs

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

type Section

type Section struct {
	AddKeysToAgent              string
	AddressFamily               string
	BindAddress                 string
	BindInterface               string
	CanonicalDomains            []string
	CanonicalizeHostname        string
	CanonicalizeMaxDots         int
	CanonicalizePermittedCNAMEs *PermittedCNAMEs
	CASignatureAlgorithms       []string
	CertificateFile             []string
	ConnectionAttempts          int
	ConnectTimeout              int

	// Environments contains system environment variables that will be
	// passed to Execute().
	// The key and value is derived from "SendEnv" and "SetEnv".
	Environments map[string]string

	Hostname string

	IdentityFile                      []string
	Port                              string
	User                              string
	XAuthLocation                     string
	IsBatchMode                       bool
	IsCanonicalizeFallbackLocal       bool
	IsChallengeResponseAuthentication bool
	IsCheckHostIP                     bool
	IsClearAllForwardings             bool
	UseCompression                    bool
	UseVisualHostKey                  bool

	// WorkingDir contains the directory where the SSH client started.
	// This value is required when client want to copy file from/to
	// remote.
	// This field is optional, default to current working directory from
	// os.Getwd() or user's home directory.
	WorkingDir string

	// The first IdentityFile that exist and valid.
	PrivateKeyFile string

	// PrivateKeys contains IdentityFile that has been parsed.
	// This field will be set once the Signers has been called.
	PrivateKeys map[string]any
	// contains filtered or unexported fields
}

Section is the type that represent SSH client Host and Match section in configuration.

func (*Section) GetIdentityAgent added in v0.32.0

func (section *Section) GetIdentityAgent() string

GetIdentityAgent get the identity agent either from section config variable IdentityAgent or from environment variable SSH_AUTH_SOCK. It will return empty string if IdentityAgent set to "none" or SSH_AUTH_SOCK is empty.

func (*Section) Signers

func (section *Section) Signers() (signers []ssh.Signer, err error)

Signers convert the IdentityFile to ssh.Signer for authentication using PublicKey and store the parsed-unsigned private key into PrivateKeys.

This method will ask for passphrase from terminal, if one of IdentityFile is protected. Unless the value of IdentityFile changes, this method should be called only once, otherwise it will ask passphrase on every call.

Jump to

Keyboard shortcuts

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