Documentation
¶
Index ¶
- func Backup(src, dest string) (string, error)
- func BackupDir() string
- func DefaultBackupPath() string
- func DefaultConfigPath() string
- func ImportFile(src, dest string) (string, string, error)
- func MigrateLegacy() (string, error)
- func PrimaryConfigPath() string
- func ResolvePath(flagPath string) string
- func Save(path string, f *File) error
- type File
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Backup ¶ added in v0.5.0
Backup copies the inventory file as-is (ciphertext and descriptions preserved). dest empty uses DefaultBackupPath().
func BackupDir ¶ added in v0.5.0
func BackupDir() string
BackupDir is ~/.sshctl/backups (same home as the primary inventory).
func DefaultBackupPath ¶ added in v0.5.0
func DefaultBackupPath() string
DefaultBackupPath returns a timestamped backup file under BackupDir.
func DefaultConfigPath ¶
func DefaultConfigPath() string
DefaultConfigPath is an alias for PrimaryConfigPath.
func ImportFile ¶ added in v0.5.0
ImportFile validates src as inventory JSON, snapshots dest if it exists, then copies src over dest.
func MigrateLegacy ¶
MigrateLegacy copies the first existing legacy inventory into PrimaryConfigPath. The source file is renamed to servers.json.bak after a successful copy. Returns the legacy source path when migration ran.
func PrimaryConfigPath ¶
func PrimaryConfigPath() string
PrimaryConfigPath returns the canonical inventory path ~/.sshctl/servers.json.
func ResolvePath ¶
ResolvePath picks config path: flag > SSHCTL_CONFIG > SSHFRAC_CONFIG > INVOSSH_CONFIG > default. Default path auto-migrates legacy ~/.sshfrac or ~/.invossh inventories to ~/.sshctl.
Types ¶
type File ¶
type File struct {
Servers []Server `json:"servers"`
}
File is the on-disk JSON document.
func (*File) Add ¶
Add inserts or updates the server for a host. Each host/IP may appear only once. Empty fields on update keep the previous values (description, ciphertext, key, …). Returns true when an existing host entry was updated.
func (*File) Find ¶
Find locates a server by name, host, or "user@host". Exact match first; if none, case-insensitive substring on name/host (must be unique).
func (*File) LookupHost ¶ added in v0.5.0
LookupHost returns the inventory entry for host/IP, or nil.
func (*File) Search ¶
Search returns servers whose name, host, or description contains keyword (case-insensitive).
func (*File) ValidateUniqueHosts ¶
ValidateUniqueHosts reports duplicate host/IP entries in the inventory.
type Server ¶
type Server struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
Password string `json:"password"`
OS string `json:"os"`
KeyFile string `json:"key_file,omitempty"`
}
Server is one SSH endpoint entry.
func (*Server) PlainPassword ¶
PlainPassword decrypts the stored password for runtime use.