skm: github.com/TimothyYe/skm Index | Files | Directories

package skm

import "github.com/TimothyYe/skm"

Index

Package Files

keytypes.go models.go utils.go

Constants

const (
    // Name is the program name
    Name = "SKM"
    // Usage is for simple description
    Usage = "Manage your multiple SSH keys easily"

    // CheckSymbol is the code for check symbol
    CheckSymbol = "\u2714 "
    // CrossSymbol is the code for check symbol
    CrossSymbol = "\u2716 "

    // PublicKey is the default name of SSH public key
    PublicKey = "id_rsa.pub"
    // PrivateKey is the default name of SSH private key
    PrivateKey = "id_rsa"
    // 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"
)

func AddCache Uses

func AddCache(alias string, keyMap map[string]*SSHKey, env *Environment) error

AddCache adds SSH to ssh agent cache via key alias

func ClearKey Uses

func ClearKey(env *Environment)

ClearKey clears both private & public keys from SSH key path

func CreateLink(alias string, keyMap map[string]*SSHKey, env *Environment)

CreateLink creates symbol link for specified SSH key

func DeleteCache Uses

func DeleteCache(alias string, keyMap map[string]*SSHKey, env *Environment) error

DeleteCache removes SSH key from SSH agent cache via key alias

func DeleteKey Uses

func DeleteKey(alias string, key *SSHKey, env *Environment, forTest ...bool)

DeleteKey delete key by its alias name

func Execute Uses

func Execute(workDir, script string, args ...string) bool

Execute executes shell commands with arguments

func Fatalf Uses

func Fatalf(format string, args ...interface{})

Fatalf output formatted fatal error info

func GetBakFileName Uses

func GetBakFileName() string

GetBakFileName generates a backup file name by current date and time

func IsEmpty Uses

func IsEmpty(path string) (bool, error)

IsEmpty checks if directory in path is empty

func ListCache Uses

func ListCache() error

ListCache lists cached SSH key from SSH agent cache

func LoadSSHKeys Uses

func LoadSSHKeys(env *Environment) map[string]*SSHKey

LoadSSHKeys loads all the SSH keys from key store

func ParsePath Uses

func ParsePath(path string) string

ParsePath return the original SSH key path if it is a symbol link

func RunHook Uses

func RunHook(alias string, env *Environment)

RunHook runs hook file after switching SSH key

type Environment Uses

type Environment struct {
    StorePath  string
    SSHPath    string
    ResticPath string
}

Environment abstracts away things like the path the .skm and .ssh folder which allows us to simulate them for testing.

type KeyType Uses

type KeyType struct {
    Name                    string
    KeyBaseName             string
    SupportsVariableBitsize bool
}

KeyType abstracts configurations for various SSH key types like RSA and ED25519

func (KeyType) PrivateKey Uses

func (kt KeyType) PrivateKey() string

PrivateKey returns the filename used by a keytype for the private component.

func (KeyType) PublicKey Uses

func (kt KeyType) PublicKey() string

PublicKey returns the filename used by a keytype for the public component.

type KeyTypeRegistry Uses

type KeyTypeRegistry map[string]KeyType

KeyTypeRegistry is used to store all the supported key types.

var SupportedKeyTypes KeyTypeRegistry

SupportedKeyTypes contains all key types supported by skm.

func (KeyTypeRegistry) GetByFilename Uses

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 SSHKey Uses

type SSHKey struct {
    PublicKey  string
    PrivateKey string
    IsDefault  bool
    Type       *KeyType
}

SSHKey struct includes both private/public keys & isDefault flag

Directories

PathSynopsis
cmd/skm

Package skm imports 9 packages (graph) and is imported by 1 packages. Updated 2020-11-26. Refresh now. Tools for package owners.