Documentation ¶
Index ¶
- Constants
- func AliasInteractiveLogin(sshConfigFile string, promptPass bool) error
- func AliasKeyCopy(hostCfgPath string, aliases []string) error
- func AliasLogin(aliasName string, promptPass bool, sshConfigFile string) error
- func BackupAll(backupPath string, env *Environment) error
- func BatchExecAlias(sshConfigPath string, promptPass bool, alias string, cmd ...string) error
- func ClusterBatchCmds(hostPattern string, PromptPass bool, login *ServerConfig, cmd ...string) error
- func ClusterCopy(args []string, PromptPass bool, login *ServerConfig) error
- func ClusterKeyCopy(hostPattern string, sshPort int, sshUser string, identityfile string) error
- func CopyKey(connectStr string, port string, keyPath string) bool
- func CopySSHKey(connectStr string, port string, env *Environment) error
- func CreateSSHKey(env *Environment) (map[string]*SSHKey, error)
- func CreateSSHlink(ctxName string, env *Environment) error
- func DeleteSSHKey(aliasName string, env *Environment) error
- func DisplaySSHKey(aliasName string, env *Environment) error
- func Displaylogo()
- func GetBakDirName(name string) string
- func InteractiveSetContext(env *Environment) error
- func KeyStoreInit(env *Environment) error
- func LoadSSHKeys(env *Environment) (map[string]*SSHKey, error)
- func NewKV(key, value string) *ssh_config.KV
- func ParseExpr(expr string) ([]string, error)
- func RenameSSHKey(aliasName string, newaliasName string, env *Environment) error
- func SetContext(cfgName string, env *Environment) error
- func SetSSHKey(aliasName string, env *Environment) (map[string]*SSHKey, error)
- type ClusterConfig
- type Clusters
- type ClustersConfig
- type Context
- type Contexts
- type DefaultClusterConfig
- type Environment
- type HostConfig
- type KeyType
- type KeyTypeRegistry
- type ListOption
- type MainConfig
- type SSHKey
- type ServerConfig
- type Servers
Constants ¶
const ( // DefaultKey is the default alias name of SSH key DefaultKey = "default" // HookName is the name of a hook that is called when present after using a key HookName = "hook" DefaultBitSize = 2048 )
const (
MaskPrompt = '*'
)
Variables ¶
This section is empty.
Functions ¶
func AliasInteractiveLogin ¶
func AliasKeyCopy ¶
func BackupAll ¶
func BackupAll(backupPath string, env *Environment) error
func BatchExecAlias ¶
func ClusterBatchCmds ¶
func ClusterBatchCmds(hostPattern string, PromptPass bool, login *ServerConfig, cmd ...string) error
batch execution of commands
func ClusterCopy ¶
func ClusterCopy(args []string, PromptPass bool, login *ServerConfig) error
func ClusterKeyCopy ¶
func CopySSHKey ¶
func CopySSHKey(connectStr string, port string, env *Environment) error
func CreateSSHKey ¶
func CreateSSHKey(env *Environment) (map[string]*SSHKey, error)
func CreateSSHlink ¶
func CreateSSHlink(ctxName string, env *Environment) error
func DeleteSSHKey ¶
func DeleteSSHKey(aliasName string, env *Environment) error
func DisplaySSHKey ¶
func DisplaySSHKey(aliasName string, env *Environment) error
func Displaylogo ¶
func Displaylogo()
func GetBakDirName ¶
GetBakFileName generates a backup dir name by current date and time
func InteractiveSetContext ¶
func InteractiveSetContext(env *Environment) error
func KeyStoreInit ¶
func KeyStoreInit(env *Environment) error
func LoadSSHKeys ¶
func LoadSSHKeys(env *Environment) (map[string]*SSHKey, error)
loads all the SSH keys from key store
func NewKV ¶
func NewKV(key, value string) *ssh_config.KV
func RenameSSHKey ¶
func RenameSSHKey(aliasName string, newaliasName string, env *Environment) error
Types ¶
type ClusterConfig ¶
type Clusters ¶
type Clusters []*ClusterConfig
func AddCluster ¶
func DeleteClusters ¶
func (Clusters) FindClusterByName ¶
func (cs Clusters) FindClusterByName(name string) (*ClusterConfig, bool)
find cluster by name
type ClustersConfig ¶
type ClustersConfig struct { Default DefaultClusterConfig `yaml:"default"` Clusters Clusters `yaml:"clusters"` // contains filtered or unexported fields }
var (
ClustersCfg ClustersConfig
)
func ClustersConfigExample ¶
func ClustersConfigExample(env *Environment) *ClustersConfig
func (*ClustersConfig) ConfigPath ¶
func (cfg *ClustersConfig) ConfigPath() string
func (*ClustersConfig) LoadFrom ¶
func (cfg *ClustersConfig) LoadFrom(filePath string) error
load nodes from yaml file
func (*ClustersConfig) SetConfigPath ¶
func (cfg *ClustersConfig) SetConfigPath(configPath string)
func (*ClustersConfig) WriteTo ¶
func (cfg *ClustersConfig) WriteTo(filePath string) error
write nodes config to yaml file
type Context ¶
type Context struct { Name string `yaml:"name"` SSHConfig string `yaml:"sshconfig"` ClusterConfig string `yaml:"clusterCfg"` }
Context myssh context
type Contexts ¶
type Contexts []Context
Contexts myssh contexts
func AddConfig ¶
func AddConfig(env *Environment) (Contexts, error)
func DeleteConfig ¶
func DeleteConfig(cfgs []string, env *Environment) (Contexts, error)
delete context
func (Contexts) FindContextByName ¶
find context by name
type DefaultClusterConfig ¶
type Environment ¶
type HostConfig ¶
type HostConfig struct { // Alias alias Alias string // Path found in which file Path string // PathMap key is file path, value is the alias's hosts PathMap map[string][]*ssh_config.Host // OwnConfig own config OwnConfig map[string]string // ImplicitConfig implicit config ImplicitConfig map[string]string }
HostConfig struct include alias, connect string and other config
func AddHostAlias ¶
func AddHostAlias(hostCfgPath string) ([]*HostConfig, error)
func DeleteAliases ¶
func DeleteAliases(p string, aliases ...string) ([]*HostConfig, error)
func ListAlias ¶
func ListAlias(p string, lo ListOption) ([]*HostConfig, error)
List ssh alias, filter by optional keyword
func UpdateHostCfg ¶
func UpdateHostCfg(hostCfgPath string, aliasName string) ([]*HostConfig, error)
func (*HostConfig) ConnectionStr ¶
func (hc *HostConfig) ConnectionStr() string
ConnectionStr return the connection string
func (*HostConfig) Display ¶
func (hc *HostConfig) Display() bool
Display Whether to display connection string
type KeyType ¶
KeyType abstracts configurations for various SSH key types like RSA and ED25519
func (KeyType) PrivateKey ¶
PrivateKey returns the filename used by a keytype for the private component.
type KeyTypeRegistry ¶
KeyTypeRegistry is used to store all the supported key types.
var SupportedKeyTypes KeyTypeRegistry
SupportedKeyTypes contains all key types supported by skm.
func (KeyTypeRegistry) GetByFilename ¶
func (r KeyTypeRegistry) GetByFilename(name string) (KeyType, bool)
GetByFilename returns a key type object given the name of the private key's file. If no matching key type could be found, then the second return value is false.
type ListOption ¶
type ListOption struct { // Keywords set Keyword filter records Keywords []string // IgnoreCase ignore case IgnoreCase bool }
ListOption options for List
type MainConfig ¶
type MainConfig struct { Basic string `yaml:"basic"` Contexts Contexts `yaml:"contexts"` Current string `yaml:"current"` // contains filtered or unexported fields }
MainConfig main config struct
var (
Main MainConfig
)
func (*MainConfig) GetConfigPath ¶
func (cfg *MainConfig) GetConfigPath() string
func (*MainConfig) LoadFrom ¶
func (cfg *MainConfig) LoadFrom(filePath string) error
load config from yaml file
func (*MainConfig) SetConfigPath ¶
func (cfg *MainConfig) SetConfigPath(configPath string)
func (*MainConfig) WriteTo ¶
func (cfg *MainConfig) WriteTo(filePath string) error
write main config to yaml file
type SSHKey ¶
type SSHKey struct { PublicKey string PrivateKey string IsDefault bool Type *KeyType KeyDesc string Alias string }
SSHKey struct includes both private/public keys & isDefault flag
type ServerConfig ¶
type ServerConfig struct { Name string `yaml:"name"` Address string `yaml:"address"` Port int `yaml:"port,omitempty"` User string `yaml:"user,omitempty"` Password string `yaml:"password,omitempty"` PrivateKey string `yaml:"privateKey,omitempty"` PrivateKeyPassword string `yaml:"privateKey_password,omitempty"` Method string `yaml:"method"` // auth method default:key,options:password、key SuRoot bool `yaml:"su_root"` UseSudo bool `yaml:"use_sudo"` NoPasswordSudo bool `yaml:"no_password_sudo"` RootPassword string `yaml:"root_password"` ServerAliveInterval time.Duration `yaml:"server_alive_interval"` }
ServerConfig server config