config

package
v2.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SSHBoolFlags = []string{"1", "2", "4", "6", "A", "a", "C", "f", "G", "g", "K", "k", "M", "N", "n", "q", "s", "T", "t", "V", "v", "X", "x", "Y", "y"}

SSHBoolFlags contains list of available SSH boolean options

View Source
var SSHFlags = []cli.Flag{}

SSHFlags is built at init(), it contains codegangsta/cli string & bool flags for SSH

View Source
var SSHStringFlags = []string{"b", "c", "D", "E", "e", "F", "I", "i", "L", "l", "m", "O", "o", "p", "Q", "R", "S", "W", "w"}

SSHStringFlags contains list of available SSH string options

Functions

func BoolVal

func BoolVal(input string) bool

BoolVal returns a boolean matching a configuration string

func SetASSHBinaryPath

func SetASSHBinaryPath(path string)

SetASSHBinaryPath sets the default assh binary path this value may be overwritten in the assh.yml file using the asshbinarypath variable

Types

type Config

type Config struct {
	Hosts             HostsMap `yaml:"hosts,omitempty,flow" json:"hosts"`
	Templates         HostsMap `yaml:"templates,omitempty,flow" json:"templates"`
	Defaults          Host     `yaml:"defaults,omitempty,flow" json:"defaults,omitempty"`
	Includes          []string `yaml:"includes,omitempty,flow" json:"includes,omitempty"`
	ASSHKnownHostFile string   `yaml:"asshknownhostfile,omitempty,flow" json:"asshknownhostfile,omitempty"`
	ASSHBinaryPath    string   `yaml:"asshbinarypath,omitempty,flow" json:"asshbinarypath,omitempty"`
	// contains filtered or unexported fields
}

Config contains a list of Hosts sections and a Defaults section representing a configuration file

func New

func New() *Config

New returns an instantiated Config object

func Open

func Open(path string) (*Config, error)

Open parses a configuration file and returns a *Config object

func (*Config) GetGatewaySafe

func (c *Config) GetGatewaySafe(name string) *Host

GetGatewaySafe returns gateway Host configuration, a gateway is like a Host, except, the host path is not resolved

func (*Config) GetHost

func (c *Config) GetHost(name string) (*Host, error)

GetHost returns a matching host form Config hosts list

func (*Config) GetHostSafe

func (c *Config) GetHostSafe(name string) *Host

GetHostSafe won't fail, in case the host is not found, it will returns a virtual host matching the pattern

func (*Config) IncludedFiles

func (c *Config) IncludedFiles() []string

IncludedFiles returns the list of the included files

func (*Config) IsConfigOutdated

func (c *Config) IsConfigOutdated(target string) (bool, error)

IsConfigOutdated returns true if .ssh/config needs to be rebuild. The reason may be: - assh.yml (or an included file) was updated recently - <target> matches a regex and was never seen before (not present in known-hosts file)

func (*Config) JsonString

func (c *Config) JsonString() ([]byte, error)

JsonString returns a string representing the JSON of a Config object

func (*Config) LoadConfig

func (c *Config) LoadConfig(source io.Reader) error

LoadConfig loads the content of an io.Reader source

func (*Config) LoadFile

func (c *Config) LoadFile(filename string) error

LoadFile loads the content of a configuration file in the Config object

func (*Config) LoadFiles

func (c *Config) LoadFiles(pattern string) error

LoadFiles will try to glob the pattern and load each maching entries

func (*Config) LoadKnownHosts

func (c *Config) LoadKnownHosts() error

LoadKnownHosts loads known hosts list from disk

func (*Config) SaveNewKnownHost

func (c *Config) SaveNewKnownHost(target string)

SaveNewKnownHost registers the target as a new known host and save the full known hosts list on disk

func (*Config) SaveSSHConfig

func (c *Config) SaveSSHConfig() error

SaveSSHConfig saves the configuration to ~/.ssh/config

func (*Config) String

func (c *Config) String() string

String returns the JSON output

func (*Config) WriteSSHConfigTo

func (c *Config) WriteSSHConfigTo(w io.Writer) error

WriteSSHConfigTo returns a .ssh/config valid file containing assh configuration

type Host

type Host struct {
	// ssh-config fields
	AddressFamily                    string `yaml:"addressfamily,omitempty,flow" json:"AddressFamily,omitempty"`
	AskPassGUI                       string `yaml:"askpassgui,omitempty,flow" json:"AskPassGUI,omitempty"`
	BatchMode                        string `yaml:"batchmode,omitempty,flow" json:"BatchMode,omitempty"`
	BindAddress                      string `yaml:"bindaddress,omitempty,flow" json:"BindAddress,omitempty"`
	CanonicalDomains                 string `yaml:"canonicaldomains,omitempty,flow" json:"CanonicalDomains,omitempty"`
	CanonicalizeFallbackLocal        string `yaml:"canonicalizefallbacklocal,omitempty,flow" json:"CanonicalizeFallbackLocal,omitempty"`
	CanonicalizeHostname             string `yaml:"canonicalizehostname,omitempty,flow" json:"CanonicalizeHostname,omitempty"`
	CanonicalizeMaxDots              string `yaml:"canonicalizemaxDots,omitempty,flow" json:"CanonicalizeMaxDots,omitempty"`
	CanonicalizePermittedCNAMEs      string `yaml:"canonicalizepermittedcnames,omitempty,flow" json:"CanonicalizePermittedCNAMEs,omitempty"`
	ChallengeResponseAuthentication  string `yaml:"challengeresponseauthentication,omitempty,flow" json:"ChallengeResponseAuthentication,omitempty"`
	CheckHostIP                      string `yaml:"checkhostip,omitempty,flow" json:"CheckHostIP,omitempty"`
	Cipher                           string `yaml:"cipher,omitempty,flow" json:"Cipher,omitempty"`
	Ciphers                          string `yaml:"ciphers,omitempty,flow" json:"Ciphers,omitempty"`
	ClearAllForwardings              string `yaml:"clearallforwardings,omitempty,flow" json:"ClearAllForwardings,omitempty"`
	Compression                      string `yaml:"compression,omitempty,flow" json:"Compression,omitempty"`
	CompressionLevel                 int    `yaml:"compressionlevel,omitempty,flow" json:"CompressionLevel,omitempty"`
	ConnectionAttempts               string `yaml:"connectionattempts,omitempty,flow" json:"ConnectionAttempts,omitempty"`
	ConnectTimeout                   int    `yaml:"connecttimeout,omitempty,flow" json:"ConnectTimeout,omitempty"`
	ControlMaster                    string `yaml:"controlmaster,omitempty,flow" json:"ControlMaster,omitempty"`
	ControlPath                      string `yaml:"controlpath,omitempty,flow" json:"ControlPath,omitempty"`
	ControlPersist                   string `yaml:"controlpersist,omitempty,flow" json:"ControlPersist,omitempty"`
	DynamicForward                   string `yaml:"dynamicforward,omitempty,flow" json:"DynamicForward,omitempty"`
	EnableSSHKeysign                 string `yaml:"enablesshkeysign,omitempty,flow" json:"EnableSSHKeysign,omitempty"`
	EscapeChar                       string `yaml:"escapechar,omitempty,flow" json:"EscapeChar,omitempty"`
	ExitOnForwardFailure             string `yaml:"exitonforwardfailure,omitempty,flow" json:"ExitOnForwardFailure,omitempty"`
	FingerprintHash                  string `yaml:"fingerprinthash,omitempty,flow" json:"FingerprintHash,omitempty"`
	ForwardAgent                     string `yaml:"forwardagent,omitempty,flow" json:"ForwardAgent,omitempty"`
	ForwardX11                       string `yaml:"forwardx11,omitempty,flow" json:"ForwardX11,omitempty"`
	ForwardX11Timeout                int    `yaml:"forwardx11timeout,omitempty,flow" json:"ForwardX11Timeout,omitempty"`
	ForwardX11Trusted                string `yaml:"forwardx11trusted,omitempty,flow" json:"ForwardX11Trusted,omitempty"`
	GatewayPorts                     string `yaml:"gatewayports,omitempty,flow" json:"GatewayPorts,omitempty"`
	GlobalKnownHostsFile             string `yaml:"globalknownhostsfile,omitempty,flow" json:"GlobalKnownHostsFile,omitempty"`
	GSSAPIAuthentication             string `yaml:"gssapiauthentication,omitempty,flow" json:"GSSAPIAuthentication,omitempty"`
	GSSAPIClientIdentity             string `yaml:"gssapiclientidentity,omitempty,flow" json:"GSSAPIClientIdentity,omitempty"`
	GSSAPIDelegateCredentials        string `yaml:"gssapidelegatecredentials,omitempty,flow" json:"GSSAPIDelegateCredentials,omitempty"`
	GSSAPIKeyExchange                string `yaml:"gssapikeyexchange,omitempty,flow" json:"GSSAPIKeyExchange,omitempty"`
	GSSAPIRenewalForcesRekey         string `yaml:"gssapirenewalforcesrekey,omitempty,flow" json:"GSSAPIRenewalForcesRekey,omitempty"`
	GSSAPIServerIdentity             string `yaml:"gssapiserveridentity,omitempty,flow" json:"GSSAPIServerIdentity,omitempty"`
	GSSAPITrustDns                   string `yaml:"gssapitrustdns,omitempty,flow" json:"GSSAPITrustDns,omitempty"`
	HashKnownHosts                   string `yaml:"hashknownhosts,omitempty,flow" json:"HashKnownHosts,omitempty"`
	HostbasedAuthentication          string `yaml:"hostbasedauthentication,omitempty,flow" json:"HostbasedAuthentication,omitempty"`
	HostbasedKeyTypes                string `yaml:"hostbasedkeytypes,omitempty,flow" json:"HostbasedKeyTypes,omitempty"`
	HostKeyAlgorithms                string `yaml:"hostkeyalgorithms,omitempty,flow" json:"HostKeyAlgorithms,omitempty"`
	HostKeyAlias                     string `yaml:"hostkeyalias,omitempty,flow" json:"HostKeyAlias,omitempty"`
	IdentitiesOnly                   string `yaml:"identitiesonly,omitempty,flow" json:"IdentitiesOnly,omitempty"`
	IdentityFile                     string `yaml:"identityfile,omitempty,flow" json:"IdentityFile,omitempty"`
	IgnoreUnknown                    string `yaml:"ignoreunknown,omitempty,flow" json:"IgnoreUnknown,omitempty"`
	IPQoS                            string `yaml:"ipqos,omitempty,flow" json:"IPQoS,omitempty"`
	KbdInteractiveAuthentication     string `yaml:"kbdinteractiveauthentication,omitempty,flow" json:"KbdInteractiveAuthentication,omitempty"`
	KbdInteractiveDevices            string `yaml:"kbdinteractivedevices,omitempty,flow" json:"KbdInteractiveDevices,omitempty"`
	KexAlgorithms                    string `yaml:"kexalgorithms,omitempty,flow" json:"KexAlgorithms,omitempty"`
	KeychainIntegration              string `yaml:"keychainintegration,omitempty,flow" json:"KeychainIntegration,omitempty"`
	LocalCommand                     string `yaml:"localcommand,omitempty,flow" json:"LocalCommand,omitempty"`
	LocalForward                     string `yaml:"localforward,omitempty,flow" json:"LocalForward,omitempty"`
	LogLevel                         string `yaml:"loglevel,omitempty,flow" json:"LogLevel,omitempty"`
	MACs                             string `yaml:"macs,omitempty,flow" json:"MACs,omitempty"`
	Match                            string `yaml:"match,omitempty,flow" json:"Match,omitempty"`
	NoHostAuthenticationForLocalhost string `yaml:"nohostauthenticationforlocalhost,omitempty,flow" json:"NoHostAuthenticationForLocalhost,omitempty"`
	NumberOfPasswordPrompts          string `yaml:"numberofpasswordprompts,omitempty,flow" json:"NumberOfPasswordPrompts,omitempty"`
	PasswordAuthentication           string `yaml:"passwordauthentication,omitempty,flow" json:"PasswordAuthentication,omitempty"`
	PermitLocalCommand               string `yaml:"permitlocalcommand,omitempty,flow" json:"PermitLocalCommand,omitempty"`
	PKCS11Provider                   string `yaml:"pkcs11provider,omitempty,flow" json:"PKCS11Provider,omitempty"`
	Port                             string `yaml:"port,omitempty,flow" json:"Port,omitempty"`
	PreferredAuthentications         string `yaml:"preferredauthentications,omitempty,flow" json:"PreferredAuthentications,omitempty"`
	Protocol                         string `yaml:"protocol,omitempty,flow" json:"Protocol,omitempty"`
	ProxyUseFdpass                   string `yaml:"proxyusefdpass,omitempty,flow" json:"ProxyUseFdpass,omitempty"`
	PubkeyAuthentication             string `yaml:"pubkeyauthentication,omitempty,flow" json:"PubkeyAuthentication,omitempty"`
	RekeyLimit                       string `yaml:"rekeylimit,omitempty,flow" json:"RekeyLimit,omitempty"`
	RemoteForward                    string `yaml:"remoteforward,omitempty,flow" json:"RemoteForward,omitempty"`
	RequestTTY                       string `yaml:"requesttty,omitempty,flow" json:"RequestTTY,omitempty"`
	RevokedHostKeys                  string `yaml:"revokedhostkeys,omitempty,flow" json:"RevokedHostKeys,omitempty"`
	RhostsRSAAuthentication          string `yaml:"rhostsrsaauthentication,omitempty,flow" json:"RhostsRSAAuthentication,omitempty"`
	RSAAuthentication                string `yaml:"rsaauthentication,omitempty,flow" json:"RSAAuthentication,omitempty"`
	SendEnv                          string `yaml:"sendenv,omitempty,flow" json:"SendEnv,omitempty"`
	ServerAliveCountMax              int    `yaml:"serveralivecountmax,omitempty,flow" json:"ServerAliveCountMax,omitempty"`
	ServerAliveInterval              int    `yaml:"serveraliveinterval,omitempty,flow" json:"ServerAliveInterval,omitempty"`
	StreamLocalBindMask              string `yaml:"streamlocalbindmask,omitempty,flow" json:"StreamLocalBindMask,omitempty"`
	StreamLocalBindUnlink            string `yaml:"streamlocalbindunlink,omitempty,flow" json:"StreamLocalBindUnlink,omitempty"`
	StrictHostKeyChecking            string `yaml:"stricthostkeychecking,omitempty,flow" json:"StrictHostKeyChecking,omitempty"`
	TCPKeepAlive                     string `yaml:"tcpkeepalive,omitempty,flow" json:"TCPKeepAlive,omitempty"`
	Tunnel                           string `yaml:"tunnel,omitempty,flow" json:"Tunnel,omitempty"`
	TunnelDevice                     string `yaml:"tunneldevice,omitempty,flow" json:"TunnelDevice,omitempty"`
	UpdateHostKeys                   string `yaml:"updatehostkeys,omitempty,flow" json:"UpdateHostKeys,omitempty"`
	UsePrivilegedPort                string `yaml:"useprivilegedport,omitempty,flow" json:"UsePrivilegedPort,omitempty"`
	User                             string `yaml:"user,omitempty,flow" json:"User,omitempty"`
	UserKnownHostsFile               string `yaml:"userknownhostsfile,omitempty,flow" json:"UserKnownHostsFile,omitempty"`
	VerifyHostKeyDNS                 string `yaml:"verifyhostkeydns,omitempty,flow" json:"VerifyHostKeyDNS,omitempty"`
	VisualHostKey                    string `yaml:"visualhostkey,omitempty,flow" json:"VisualHostKey,omitempty"`
	XAuthLocation                    string `yaml:"xauthlocation,omitempty,flow" json:"XAuthLocation,omitempty"`

	// ssh-config fields with a different behavior
	HostName     string `yaml:"hostname,omitempty,flow" json:"HostName,omitempty"`
	ProxyCommand string `yaml:"proxycommand,omitempty,flow" json:"ProxyCommand,omitempty"`

	// exposed assh fields
	Inherits             []string `yaml:"inherits,omitempty,flow" json:"Inherits,omitempty"`
	Gateways             []string `yaml:"gateways,omitempty,flow" json:"Gateways,omitempty"`
	ResolveNameservers   []string `yaml:"resolvenameservers,omitempty,flow" json:"ResolveNameservers,omitempty"`
	ResolveCommand       string   `yaml:"resolvecommand,omitempty,flow" json:"ResolveCommand,omitempty"`
	NoControlMasterMkdir string   `yaml:"nocontrolmastermkdir,omitempty,flow" json:"NoControlMasterMkdir,omitempty"`
	Aliases              []string `yaml:"aliases,omitempty,flow" json:"Aliases,omitempty"`
	// contains filtered or unexported fields
}

Host defines the configuration flags of a host

func NewHost

func NewHost(name string) *Host

NewHost returns a host with name

func (*Host) AddKnownHost

func (h *Host) AddKnownHost(target string)

AddKnownHost append target to the host' known hosts list

func (*Host) ApplyDefaults

func (h *Host) ApplyDefaults(defaults *Host)

ApplyDefaults ensures a Host is valid by filling the missing fields with defaults

func (*Host) Clone

func (h *Host) Clone() *Host

Clone returns a copy of an existing Host

func (*Host) ExpandString

func (h *Host) ExpandString(input string) string

func (*Host) Matches

func (h *Host) Matches(needle string) bool

Matches returns true if the host matches a given string

func (*Host) Name

func (h *Host) Name() string

Name returns the name of a host

func (*Host) Options

func (h *Host) Options() OptionsList

Options returns a map of set options

func (*Host) Prototype

func (h *Host) Prototype() string

Prototype returns a prototype representation of the host, used in listings

func (*Host) String

func (h *Host) String() string

String returns the JSON output

func (*Host) WriteSSHConfigTo

func (h *Host) WriteSSHConfigTo(w io.Writer) error

WriteSSHConfigTo writes an ~/.ssh/config file compatible host definition to a writable stream

type HostsList

type HostsList []*Host

HostsList is a list of *Host

func (HostsList) Len

func (hl HostsList) Len() int

func (HostsList) Less

func (hl HostsList) Less(i, j int) bool

func (HostsList) Swap

func (hl HostsList) Swap(i, j int)

type HostsMap

type HostsMap map[string]*Host

HostsMap is a map of **Host).Name -> *Host

func (*HostsMap) SortedList

func (hm *HostsMap) SortedList() HostsList

SortedList returns a list of hosts sorted by their name

func (*HostsMap) ToList

func (hm *HostsMap) ToList() HostsList

ToList returns a slice of *Hosts

type Option

type Option struct {
	Name  string
	Value string
}

Option is an host option

func (*Option) String

func (o *Option) String() string

type OptionsList

type OptionsList []Option

OptionsList is a list of options

func (*OptionsList) Remove

func (ol *OptionsList) Remove(key string)

Remove removes an option from the list based on its key

func (*OptionsList) ToStringList

func (ol *OptionsList) ToStringList() []string

ToStringList returns a list of string with the following format: `key=value`

Jump to

Keyboard shortcuts

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