Documentation ¶
Overview ¶
Package config provide the ssh_config(5) parser and getter.
Index ¶
- Constants
- type Config
- type PermittedCNAMEs
- type Section
- func (section *Section) CASignatureAlgorithms() []string
- func (section *Section) CanonicalDomains() []string
- func (section *Section) CanonicalizePermittedCNames() (pcnames *PermittedCNAMEs, err error)
- func (section *Section) CertificateFile() []string
- func (section *Section) Environments(sysEnv map[string]string) (env map[string]string)
- func (section *Section) FieldBool(key string) (vbool bool)
- func (section *Section) FieldInt(key string) (vint int)
- func (section *Section) Hostname() string
- func (section *Section) IdentityAgent() string
- func (section *Section) Port() string
- func (section *Section) Set(key, value string) (err error)
- func (section *Section) Signers() (signers []ssh.Signer, err error)
- func (section *Section) User() string
Constants ¶
const ( // List of key in Host or Match with single, string value. KeyAddKeysToAgent = `addkeystoagent` KeyAddressFamily = `addressfamily` KeyBindAddress = `bindaddress` KeyBindInterface = `bindinterface` KeyCanonicalizeHostname = `canonicalizehostname` KeySetEnv = `setenv` KeyXAuthLocation = `xauthlocation` // List of key in Host or Match with multiple, string values. KeyCASignatureAlgorithms = `casignaturealgorithms` KeyCanonicalDomains = `canonicaldomains` KeyCertificateFile = `certificatefile` KeyIdentityFile = `identityfile` KeySendEnv = `sendenv` // List of key in Host or Match with integer value. KeyCanonicalizeMaxDots = `canonicalizemaxdots` KeyConnectTimeout = `connecttimeout` KeyConnectionAttempts = `connectionattempts` // List of key in Host or Match with boolean value. KeyBatchMode = `batchmode` KeyCanonicalizeFallbackLocal = `canonicalizefallbacklocal` KeyChallengeResponseAuthentication = `challengeresponseauthentication` KeyCheckHostIP = `checkhostip` KeyClearAllForwardings = `clearallforwardings` KeyCompression = `compression` KeyVisualHostKey = `visualhostkey` // List of key in Host or Match with value fetched using method. KeyCanonicalizePermittedCNames = `canonicalizepermittedcnames` KeyHostname = `hostname` KeyIdentityAgent = `identityagent` KeyPort = `port` KeyUser = `user` )
List of valid keys in Host or Match section.
const ( ValueAlways = `always` ValueAsk = `ask` ValueConfirm = `confirm` ValueNo = `no` ValueYes = `yes` )
Valid values for key AddKeysToAgent.
const ( ValueAny = `any` ValueInet = `inet` ValueInet6 = `inet6` )
Valid values for key AddressFamily.
const ( DefConnectionAttempts = `1` DefPort = `22` DefXAuthLocation = `/usr/X11R6/bin/xauth` )
List of default key value.
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.
type PermittedCNAMEs ¶
type PermittedCNAMEs struct {
// contains filtered or unexported fields
}
type Section ¶
type Section struct { // PrivateKeys contains IdentityFile that has been parsed. // This field will be set once the Signers has been called. PrivateKeys map[string]any // Field store the unpacked key and value of Section. // For section key that is not expecting string value, one can use // FieldBool or FieldInt. Field map[string]string // The first IdentityFile that exist and valid. PrivateKeyFile string // 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 IdentityFile []string // contains filtered or unexported fields }
Section is the type that represent SSH client Host and Match section in configuration.
func (*Section) CASignatureAlgorithms ¶
CASignatureAlgorithms return list of signature algorithms set from KeyCASignatureAlgorithms. If not set it will return the default CA signature algorithms.
func (*Section) CanonicalDomains ¶
CanonicalDomains return list CanonicalDomains set in Section.
func (*Section) CanonicalizePermittedCNames ¶ added in v0.49.0
func (section *Section) CanonicalizePermittedCNames() (pcnames *PermittedCNAMEs, err error)
CanonicalizePermittedCNames return the permitted CNAMEs set in Section, from KeyCanonicalizePermittedCNames.
func (*Section) CertificateFile ¶
CertificateFile return list of certificate file, if its set in Host or Match configuration.
func (*Section) Environments ¶
Environments return system and/or custom environment that will be passed to remote machine. The key and value is derived from "SendEnv" and "SetEnv".
func (*Section) FieldBool ¶ added in v0.49.0
FieldBool get the Field value as boolean. It will return false if key is not exist or value is invalid.
func (*Section) FieldInt ¶ added in v0.49.0
FieldInt get the Field value as int. It the value is unparseable as numeric it will return 0.
func (*Section) IdentityAgent ¶ added in v0.49.0
IdentityAgent get the identity agent either from section config variable "IdentityAgent" or from environment variable SSH_AUTH_SOCK.
There are four possible value: SSH_AUTH_SOCK, <$STRING>, <PATH>, or "none". If SSH_AUTH_SOCK, the socket path is read from the environment variable SSH_AUTH_SOCK. If value start with "$", then the socket path is set based on value of that environment variable. Other string beside "none" will be considered as path to socket.
It will return empty string if IdentityAgent set to "none" or SSH_AUTH_SOCK is empty.
func (*Section) Signers ¶
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.