Documentation
¶
Index ¶
- func GenerateLSSHConfigFromOpenSSH(path, command string) ([]byte, error)
- func GetNameList(listConf Config) (nameList []string)
- func HandleGenerateConfigMode(path string, out io.Writer) (bool, error)
- type Config
- type ControlPersistDuration
- type IncludeConfig
- type IncludesConfig
- type LogConfig
- type MuxConfig
- type OpenSSHConfig
- type PortForward
- type ProxyConfig
- type ServerConfig
- type ServerMatchConfig
- type ServerMatchWhen
- type ShellAliasConfig
- type ShellConfig
- type ShellOutexecCmdConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateLSSHConfigFromOpenSSH ¶ added in v0.9.0
GenerateLSSHConfigFromOpenSSH renders OpenSSH host entries as a minimal lssh config file that can be written to stdout or saved by the caller.
func GetNameList ¶
GetNameList return a list of server names from the Config structure.
Types ¶
type Config ¶
type Config struct {
Log LogConfig `toml:"log" yaml:"log"`
Mux MuxConfig `toml:"mux" yaml:"mux"`
Shell ShellConfig `toml:"shell" yaml:"shell"`
Include map[string]IncludeConfig `toml:"include" yaml:"include"`
Includes IncludesConfig `toml:"includes" yaml:"includes"`
Common ServerConfig `toml:"common" yaml:"common"`
Server map[string]ServerConfig `toml:"server" yaml:"server"`
Proxy map[string]ProxyConfig `toml:"proxy" yaml:"proxy"`
SSHConfig map[string]OpenSSHConfig `toml:"sshconfig" yaml:"sshconfig"`
}
Config is Struct that stores the entire configuration file.
func Read ¶
ReadConf load configuration file and return Config structure TODO(blacknon): リファクタリング!(v0.6.5) 外出しや処理のまとめなど
func ReadWithFallback ¶ added in v0.9.0
ReadWithFallback loads the lssh config, falls back to OpenSSH import mode when the file does not exist, and optionally offers to create the missing file in interactive sessions.
func (*Config) ReadIncludeFiles ¶
func (c *Config) ReadIncludeFiles()
ReadIncludeFiles read include files and append to Config.Server.
func (*Config) ReadOpenSSHConfig ¶
func (c *Config) ReadOpenSSHConfig()
ReadOpenSSHConfig read OpenSSH config file and append to Config.Server.
func (*Config) ReduceCommon ¶
func (c *Config) ReduceCommon()
ReduceCommon reduce common setting (in .lssh.conf servers)
func (*Config) ResolveConditionalMatches ¶ added in v0.8.0
type ControlPersistDuration ¶
type ControlPersistDuration int
ControlPersistDuration stores ControlPersist in seconds while allowing TOML/OpenSSH duration strings.
func (*ControlPersistDuration) UnmarshalTOML ¶
func (d *ControlPersistDuration) UnmarshalTOML(v interface{}) error
func (*ControlPersistDuration) UnmarshalYAML ¶ added in v0.9.0
func (d *ControlPersistDuration) UnmarshalYAML(unmarshal func(interface{}) error) error
type IncludeConfig ¶
type IncludeConfig struct {
Path string `toml:"path" yaml:"path"`
}
IncludeConfig specify the configuration file to include (ServerConfig only).
type IncludesConfig ¶
type IncludesConfig struct {
// example:
// path = [
// "~/.lssh.d/home.conf"
// ,"~/.lssh.d/cloud.conf"
// ]
Path []string `toml:"path" yaml:"path"`
}
IncludesConfig specify the configuration file to include (ServerConfig only). Struct that can specify multiple files in array. TODO: ワイルドカード指定可能にする
type LogConfig ¶
type LogConfig struct {
// Enable terminal logging.
Enable bool `toml:"enable" yaml:"enable"`
// Add a timestamp at the beginning of the terminal log line.
Timestamp bool `toml:"timestamp" yaml:"timestamp"`
// Specifies the directory for creating terminal logs.
Dir string `toml:"dirpath" yaml:"dirpath"`
// Logging with remove ANSI code.
RemoveAnsiCode bool `toml:"remove_ansi_code" yaml:"remove_ansi_code"`
}
LogConfig store the contents about the terminal log. The log file name is created in "YYYYmmdd_HHMMSS_servername.log" of the specified directory.
type MuxConfig ¶ added in v0.8.0
type MuxConfig struct {
Prefix string `toml:"prefix" yaml:"prefix"`
Quit string `toml:"quit" yaml:"quit"`
NewPage string `toml:"new_page" yaml:"new_page"`
NewPane string `toml:"new_pane" yaml:"new_pane"`
SplitHorizontal string `toml:"split_horizontal" yaml:"split_horizontal"`
SplitVertical string `toml:"split_vertical" yaml:"split_vertical"`
NextPane string `toml:"next_pane" yaml:"next_pane"`
NextPage string `toml:"next_page" yaml:"next_page"`
PrevPage string `toml:"prev_page" yaml:"prev_page"`
PageList string `toml:"page_list" yaml:"page_list"`
ClosePane string `toml:"close_pane" yaml:"close_pane"`
Broadcast string `toml:"broadcast" yaml:"broadcast"`
Transfer string `toml:"transfer" yaml:"transfer"`
FocusBorderColor string `toml:"focus_border_color" yaml:"focus_border_color"`
FocusTitleColor string `toml:"focus_title_color" yaml:"focus_title_color"`
BroadcastBorderColor string `toml:"broadcast_border_color" yaml:"broadcast_border_color"`
BroadcastTitleColor string `toml:"broadcast_title_color" yaml:"broadcast_title_color"`
DoneBorderColor string `toml:"done_border_color" yaml:"done_border_color"`
DoneTitleColor string `toml:"done_title_color" yaml:"done_title_color"`
}
MuxConfig stores lsmux key bindings.
func (MuxConfig) ApplyDefaults ¶ added in v0.8.0
ApplyDefaults fills empty key bindings with tmux-like defaults.
type OpenSSHConfig ¶
type OpenSSHConfig struct {
Path string `toml:"path" yaml:"path"` // This is preferred
Command string `toml:"command" yaml:"command"`
When ServerMatchWhen `toml:"when" yaml:"when"`
ServerConfig
}
OpenSSHConfig is read OpenSSH configuration file.
type PortForward ¶
type PortForward struct {
Mode string // L or R.
Local string // localhost:8080 or /tmp/local.sock
Remote string // localhost:80 or /tmp/remote.sock
LocalNetwork string // tcp or unix
RemoteNetwork string // tcp or unix
}
PortForward
type ProxyConfig ¶
type ProxyConfig struct {
Addr string `toml:"addr" yaml:"addr"`
Port string `toml:"port" yaml:"port"`
User string `toml:"user" yaml:"user"`
Pass string `toml:"pass" yaml:"pass"`
Proxy string `toml:"proxy" yaml:"proxy"`
ProxyType string `toml:"proxy_type" yaml:"proxy_type"`
Note string `toml:"note" yaml:"note"`
}
ProxyConfig is that stores Proxy server settings connected via http and socks5.
type ServerConfig ¶
type ServerConfig struct {
// Connect basic Setting
Addr string `toml:"addr" yaml:"addr"`
Port string `toml:"port" yaml:"port"`
User string `toml:"user" yaml:"user"`
// Connect auth Setting
Pass string `toml:"pass" yaml:"pass"`
Passes []string `toml:"passes" yaml:"passes"`
Key string `toml:"key" yaml:"key"`
KeyCommand string `toml:"keycmd" yaml:"keycmd"`
KeyCommandPass string `toml:"keycmdpass" yaml:"keycmdpass"`
KeyPass string `toml:"keypass" yaml:"keypass"`
Keys []string `toml:"keys" yaml:"keys"` // "keypath::passphrase"
Cert string `toml:"cert" yaml:"cert"`
Certs []string `toml:"certs" yaml:"certs"` // "certpath::keypath::passphrase"
CertKey string `toml:"certkey" yaml:"certkey"`
CertKeyPass string `toml:"certkeypass" yaml:"certkeypass"`
CertPKCS11 bool `toml:"certpkcs11" yaml:"certpkcs11"`
AgentAuth bool `toml:"agentauth" yaml:"agentauth"`
SSHAgentUse bool `toml:"ssh_agent" yaml:"ssh_agent"`
SSHAgentKeyPath []string `toml:"ssh_agent_key" yaml:"ssh_agent_key"` // "keypath::passphrase"
PKCS11Use bool `toml:"pkcs11" yaml:"pkcs11"`
PKCS11Provider string `toml:"pkcs11provider" yaml:"pkcs11provider"` // PKCS11 Provider PATH
PKCS11PIN string `toml:"pkcs11pin" yaml:"pkcs11pin"` // PKCS11 PIN code
// pre execute command
PreCmd string `toml:"pre_cmd" yaml:"pre_cmd"`
// post execute command
PostCmd string `toml:"post_cmd" yaml:"post_cmd"`
// proxy setting
ProxyType string `toml:"proxy_type" yaml:"proxy_type"`
Proxy string `toml:"proxy" yaml:"proxy"`
// OpenSSH type proxy setting
ProxyCommand string `toml:"proxy_cmd" yaml:"proxy_cmd"`
// local rcfile setting
// yes|no (default: yes)
LocalRcUse string `toml:"local_rc" yaml:"local_rc"`
// LocalRcPath
LocalRcPath []string `toml:"local_rc_file" yaml:"local_rc_file"`
// If LocalRcCompress is true, gzip the localrc file to base64
LocalRcCompress bool `toml:"local_rc_compress" yaml:"local_rc_compress"`
// LocalRcDecodeCmd is localrc decode command. run remote machine.
LocalRcDecodeCmd string `toml:"local_rc_decode_cmd" yaml:"local_rc_decode_cmd"`
// LocalRcUncompressCmd is localrc un compress command. run remote machine.
LocalRcUncompressCmd string `toml:"local_rc_uncompress_cmd" yaml:"local_rc_uncompress_cmd"`
// local/remote port forwarding setting.
// ex. [`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]
PortForwardMode string `toml:"port_forward" yaml:"port_forward"`
// port forward (local). "host:port"
PortForwardLocal string `toml:"port_forward_local" yaml:"port_forward_local"`
// port forward (remote). "host:port"
PortForwardRemote string `toml:"port_forward_remote" yaml:"port_forward_remote"`
// local/remote port forwarding settings
// ex. {[`L`,`l`,`LOCAL`,`local`]|[`R`,`r`,`REMOTE`,`remote`]}:[localaddress]:[localport]:[remoteaddress]:[remoteport]
PortForwards []string `toml:"port_forwards" yaml:"port_forwards"`
// local/remote Port Forwarding slice.
Forwards []*PortForward
// Dynamic Port Forward setting
// ex.) "11080"
DynamicPortForward string `toml:"dynamic_port_forward" yaml:"dynamic_port_forward"`
// Reverse Dynamic Port Forward setting
// ex.) "11080"
ReverseDynamicPortForward string `toml:"reverse_dynamic_port_forward" yaml:"reverse_dynamic_port_forward"`
// HTTP Dynamic Port Forward setting
// ex.) "11080"
HTTPDynamicPortForward string `toml:"http_dynamic_port_forward" yaml:"http_dynamic_port_forward"`
// HTTP Reverse Dynamic Port Forward setting
// ex.) "11080"
HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward" yaml:"http_reverse_dynamic_port_forward"`
// NFS Dynamic Forward port setting
// ex.) "12049"
NFSDynamicForwardPort string `toml:"nfs_dynamic_forward" yaml:"nfs_dynamic_forward"`
// NFS Dynamic Forward path setting
// ex.) "/path/to/remote"
NFSDynamicForwardPath string `toml:"nfs_dynamic_forward_path" yaml:"nfs_dynamic_forward_path"`
// NFS Reverse Dynamic Forward port setting
// ex.) "12049"
NFSReverseDynamicForwardPort string `toml:"nfs_reverse_dynamic_forward" yaml:"nfs_reverse_dynamic_forward"`
// NFS Reverse Dynamic Forward path setting
// ex.) "/path/to/local"
NFSReverseDynamicForwardPath string `toml:"nfs_reverse_dynamic_forward_path" yaml:"nfs_reverse_dynamic_forward_path"`
// SMB Dynamic Forward port setting
// ex.) "12445"
SMBDynamicForwardPort string `toml:"smb_dynamic_forward" yaml:"smb_dynamic_forward"`
// SMB Dynamic Forward path setting
// ex.) "/path/to/remote"
SMBDynamicForwardPath string `toml:"smb_dynamic_forward_path" yaml:"smb_dynamic_forward_path"`
// SMB Reverse Dynamic Forward port setting
// ex.) "12445"
SMBReverseDynamicForwardPort string `toml:"smb_reverse_dynamic_forward" yaml:"smb_reverse_dynamic_forward"`
// SMB Reverse Dynamic Forward path setting
// ex.) "/path/to/local"
SMBReverseDynamicForwardPath string `toml:"smb_reverse_dynamic_forward_path" yaml:"smb_reverse_dynamic_forward_path"`
// x11 forwarding setting
X11 bool `toml:"x11" yaml:"x11"`
// x11 trusted forwarding setting
X11Trusted bool `toml:"x11_trusted" yaml:"x11_trusted"`
// Connection Timeout second
ConnectTimeout int `toml:"connect_timeout" yaml:"connect_timeout"`
// Server Alive
ServerAliveCountMax int `toml:"alive_max" yaml:"alive_max"`
ServerAliveCountInterval int `toml:"alive_interval" yaml:"alive_interval"`
// Check KnownHosts
CheckKnownHosts bool `toml:"check_known_hosts" yaml:"check_known_hosts"`
// Check KnownHosts File
KnownHostsFiles []string `toml:"known_hosts_files" yaml:"known_hosts_files"`
// OpenSSH ControlMaster settings
ControlMaster bool `toml:"control_master" yaml:"control_master"`
ControlPath string `toml:"control_path" yaml:"control_path"`
ControlPersist ControlPersistDuration `toml:"control_persist" yaml:"control_persist"`
// note
Note string `toml:"note" yaml:"note"`
// ignore this server from selection / execution targets
Ignore bool `toml:"ignore" yaml:"ignore"`
// Conditional overrides under [server.<name>.match.<branch>]
Match map[string]ServerMatchConfig `toml:"match" yaml:"match"`
}
ServerConfig Structure for holding SSH connection information
type ServerMatchConfig ¶ added in v0.8.0
type ServerMatchConfig struct {
Addr string `toml:"addr" yaml:"addr"`
Port string `toml:"port" yaml:"port"`
User string `toml:"user" yaml:"user"`
Pass string `toml:"pass" yaml:"pass"`
Passes []string `toml:"passes" yaml:"passes"`
Key string `toml:"key" yaml:"key"`
KeyCommand string `toml:"keycmd" yaml:"keycmd"`
KeyCommandPass string `toml:"keycmdpass" yaml:"keycmdpass"`
KeyPass string `toml:"keypass" yaml:"keypass"`
Keys []string `toml:"keys" yaml:"keys"`
Cert string `toml:"cert" yaml:"cert"`
Certs []string `toml:"certs" yaml:"certs"`
CertKey string `toml:"certkey" yaml:"certkey"`
CertKeyPass string `toml:"certkeypass" yaml:"certkeypass"`
CertPKCS11 bool `toml:"certpkcs11" yaml:"certpkcs11"`
AgentAuth bool `toml:"agentauth" yaml:"agentauth"`
SSHAgentUse bool `toml:"ssh_agent" yaml:"ssh_agent"`
SSHAgentKeyPath []string `toml:"ssh_agent_key" yaml:"ssh_agent_key"`
PKCS11Use bool `toml:"pkcs11" yaml:"pkcs11"`
PKCS11Provider string `toml:"pkcs11provider" yaml:"pkcs11provider"`
PKCS11PIN string `toml:"pkcs11pin" yaml:"pkcs11pin"`
PreCmd string `toml:"pre_cmd" yaml:"pre_cmd"`
PostCmd string `toml:"post_cmd" yaml:"post_cmd"`
ProxyType string `toml:"proxy_type" yaml:"proxy_type"`
Proxy string `toml:"proxy" yaml:"proxy"`
ProxyCommand string `toml:"proxy_cmd" yaml:"proxy_cmd"`
LocalRcUse string `toml:"local_rc" yaml:"local_rc"`
LocalRcPath []string `toml:"local_rc_file" yaml:"local_rc_file"`
LocalRcCompress bool `toml:"local_rc_compress" yaml:"local_rc_compress"`
LocalRcDecodeCmd string `toml:"local_rc_decode_cmd" yaml:"local_rc_decode_cmd"`
LocalRcUncompressCmd string `toml:"local_rc_uncompress_cmd" yaml:"local_rc_uncompress_cmd"`
PortForwardMode string `toml:"port_forward" yaml:"port_forward"`
PortForwardLocal string `toml:"port_forward_local" yaml:"port_forward_local"`
PortForwardRemote string `toml:"port_forward_remote" yaml:"port_forward_remote"`
PortForwards []string `toml:"port_forwards" yaml:"port_forwards"`
Forwards []*PortForward
DynamicPortForward string `toml:"dynamic_port_forward" yaml:"dynamic_port_forward"`
ReverseDynamicPortForward string `toml:"reverse_dynamic_port_forward" yaml:"reverse_dynamic_port_forward"`
HTTPDynamicPortForward string `toml:"http_dynamic_port_forward" yaml:"http_dynamic_port_forward"`
HTTPReverseDynamicPortForward string `toml:"http_reverse_dynamic_port_forward" yaml:"http_reverse_dynamic_port_forward"`
NFSDynamicForwardPort string `toml:"nfs_dynamic_forward" yaml:"nfs_dynamic_forward"`
NFSDynamicForwardPath string `toml:"nfs_dynamic_forward_path" yaml:"nfs_dynamic_forward_path"`
NFSReverseDynamicForwardPort string `toml:"nfs_reverse_dynamic_forward" yaml:"nfs_reverse_dynamic_forward"`
NFSReverseDynamicForwardPath string `toml:"nfs_reverse_dynamic_forward_path" yaml:"nfs_reverse_dynamic_forward_path"`
SMBDynamicForwardPort string `toml:"smb_dynamic_forward" yaml:"smb_dynamic_forward"`
SMBDynamicForwardPath string `toml:"smb_dynamic_forward_path" yaml:"smb_dynamic_forward_path"`
SMBReverseDynamicForwardPort string `toml:"smb_reverse_dynamic_forward" yaml:"smb_reverse_dynamic_forward"`
SMBReverseDynamicForwardPath string `toml:"smb_reverse_dynamic_forward_path" yaml:"smb_reverse_dynamic_forward_path"`
X11 bool `toml:"x11" yaml:"x11"`
X11Trusted bool `toml:"x11_trusted" yaml:"x11_trusted"`
ConnectTimeout int `toml:"connect_timeout" yaml:"connect_timeout"`
ServerAliveCountMax int `toml:"alive_max" yaml:"alive_max"`
ServerAliveCountInterval int `toml:"alive_interval" yaml:"alive_interval"`
CheckKnownHosts bool `toml:"check_known_hosts" yaml:"check_known_hosts"`
KnownHostsFiles []string `toml:"known_hosts_files" yaml:"known_hosts_files"`
ControlMaster bool `toml:"control_master" yaml:"control_master"`
ControlPath string `toml:"control_path" yaml:"control_path"`
ControlPersist ControlPersistDuration `toml:"control_persist" yaml:"control_persist"`
Note string `toml:"note" yaml:"note"`
Ignore bool `toml:"ignore" yaml:"ignore"`
Priority int `toml:"priority" yaml:"priority"`
When ServerMatchWhen `toml:"when" yaml:"when"`
// contains filtered or unexported fields
}
ServerMatchConfig stores a single conditional override branch.
Keep override fields aligned with ServerConfig so branch tables can override the same keys as normal server definitions.
func (ServerMatchConfig) EffectivePriority ¶ added in v0.8.0
func (m ServerMatchConfig) EffectivePriority() int
EffectivePriority returns the branch priority, defaulting to 100 when omitted.
func (ServerMatchConfig) IsDefined ¶ added in v0.8.0
func (m ServerMatchConfig) IsDefined(key string) bool
IsDefined reports whether the TOML key was explicitly set in the match branch.
func (ServerMatchConfig) OverrideConfig ¶ added in v0.8.0
func (m ServerMatchConfig) OverrideConfig() ServerConfig
OverrideConfig converts a branch override into a ServerConfig for merging.
type ServerMatchWhen ¶ added in v0.8.0
type ServerMatchWhen struct {
LocalIPIn []string `toml:"local_ip_in" yaml:"local_ip_in"`
LocalIPNotIn []string `toml:"local_ip_not_in" yaml:"local_ip_not_in"`
GatewayIn []string `toml:"gateway_in" yaml:"gateway_in"`
GatewayNotIn []string `toml:"gateway_not_in" yaml:"gateway_not_in"`
UsernameIn []string `toml:"username_in" yaml:"username_in"`
UsernameNotIn []string `toml:"username_not_in" yaml:"username_not_in"`
HostnameIn []string `toml:"hostname_in" yaml:"hostname_in"`
HostnameNotIn []string `toml:"hostname_not_in" yaml:"hostname_not_in"`
OSIn []string `toml:"os_in" yaml:"os_in"`
OSNotIn []string `toml:"os_not_in" yaml:"os_not_in"`
TermIn []string `toml:"term_in" yaml:"term_in"`
TermNotIn []string `toml:"term_not_in" yaml:"term_not_in"`
EnvIn []string `toml:"env_in" yaml:"env_in"`
EnvNotIn []string `toml:"env_not_in" yaml:"env_not_in"`
EnvValueIn []string `toml:"env_value_in" yaml:"env_value_in"`
EnvValueNotIn []string `toml:"env_value_not_in" yaml:"env_value_not_in"`
}
ServerMatchWhen stores match conditions for conditional server overrides.
func (ServerMatchWhen) Empty ¶ added in v0.8.0
func (w ServerMatchWhen) Empty() bool
Empty reports whether no match conditions are defined.
type ShellAliasConfig ¶
type ShellAliasConfig struct {
// command
Command string `toml:"command" yaml:"command"`
}
type ShellConfig ¶
type ShellConfig struct {
// prompt
Prompt string `toml:"PROMPT" yaml:"PROMPT"` // lssh shell(parallel shell) prompt
OPrompt string `toml:"OPROMPT" yaml:"OPROMPT"` // lssh shell(parallel shell) output prompt
// message,title etc...
Title string `toml:"title" yaml:"title"`
// history file
HistoryFile string `toml:"histfile" yaml:"histfile"`
// pre | post command setting
PreCmd string `toml:"pre_cmd" yaml:"pre_cmd"`
PostCmd string `toml:"post_cmd" yaml:"post_cmd"`
// alias
Alias map[string]ShellAliasConfig `toml:"alias" yaml:"alias"`
// outexec
OutexecCmdConfigs map[string]ShellOutexecCmdConfig `toml:"outexecs" yaml:"outexecs"`
}
ShellConfig Structure for storing lssh-shell(parallel shell) settings.
type ShellOutexecCmdConfig ¶
type ShellOutexecCmdConfig struct {
// path
Path string `toml:"path" yaml:"path"`
}
OutexecCmdConfig