config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 6 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 DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath is an alias for PrimaryConfigPath.

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 replaces the server for a host. Each host/IP may appear only once. Returns true when an existing host entry was replaced.

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) 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