config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup added in v0.5.0

func Backup(src, dest string) (string, error)

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

func ImportFile(src, dest string) (string, string, error)

ImportFile validates src as inventory JSON, snapshots dest if it exists, then copies src over dest.

func MigrateLegacy

func MigrateLegacy() (string, error)

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

func ResolvePath(flagPath string) string

ResolvePath picks config path: flag > SSHCTL_CONFIG > SSHFRAC_CONFIG > INVOSSH_CONFIG > default. Default path auto-migrates legacy ~/.sshfrac or ~/.invossh inventories to ~/.sshctl.

func Save

func Save(path string, f *File) error

Save writes JSON with indentation.

Types

type File

type File struct {
	Servers []Server `json:"servers"`
}

File is the on-disk JSON document.

func Load

func Load(path string) (*File, error)

Load reads JSON, encrypts any plaintext passwords, and rewrites the file when needed.

func (*File) Add

func (f *File) Add(s Server) (bool, error)

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

func (f *File) Find(query string) (*Server, error)

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

func (f *File) LookupHost(host string) *Server

LookupHost returns the inventory entry for host/IP, or nil.

func (*File) Search

func (f *File) Search(keyword string) []*Server

Search returns servers whose name, host, or description contains keyword (case-insensitive).

func (*File) ValidateUniqueHosts

func (f *File) ValidateUniqueHosts() error

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

func (s *Server) PlainPassword() (string, error)

PlainPassword decrypts the stored password for runtime use.

Jump to

Keyboard shortcuts

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