config

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2016 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASSHBinary = "assh"
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 ExpandEnvSafe

func ExpandEnvSafe(s string) string

ExpandEnvSafe replaces ${var} or $var in the string according to the values of the current environment variables. As opposed to os.ExpandEnv, ExpandEnvSafe won't remove the dollar in '$(...)' See https://golang.org/src/os/env.go?s=963:994#L22 for the original function

func GetHomeDir

func GetHomeDir() string

GetHomeDir returns '~' as a path

Types

type Config

type Config struct {
	Hosts             map[string]*Host `yaml:"hosts,omitempty,flow" json:"hosts"`
	Templates         map[string]*Host `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"`
	// 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() (*Config, error)

Open returns a Config object loaded with standard configuration file paths

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) WriteSshConfigTo

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

ExportSshConfig 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) Name

func (h *Host) Name() string

Name returns the name of a host

func (*Host) WriteSshConfigTo

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

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

Jump to

Keyboard shortcuts

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