Documentation
¶
Index ¶
- Constants
- Variables
- func AddHost(settings *Settings, host HostConfig) error
- func GetSettingsDir() (string, error)
- func GetSettingsPath() (string, error)
- func HandleHostManagement(config *sshclient.Config) error
- func HandlePasswordManagement(config *sshclient.Config) error
- func HandleTransfer(config *sshclient.Config) (err error)
- func ParseArgs(args []string) *sshclient.Config
- func PrintUsage()
- func RemoveHost(settings *Settings, name string) error
- func Run(args []string) (err error)
- func SaveSettings(settings *Settings) error
- func UpdateHost(settings *Settings, host HostConfig) error
- func ValidateHostConfig(host *HostConfig) error
- type ExitError
- type HostConfig
- type Settings
Constants ¶
const ( // SettingsDir is the directory where settings are stored SettingsDir = ".sshx" // SettingsFile is the name of the settings file SettingsFile = "settings.json" // DefaultHostType is the default system type assigned to a host DefaultHostType = "linux" )
Variables ¶
var ErrReported = errors.New("result already reported")
ErrReported signals that a structured (JSON) result has already been written to stdout, so the entry point should exit without printing anything further.
var ErrUsage = errors.New("usage displayed")
ErrUsage is returned when only the usage information was printed.
var Version = "dev"
Version is the sshx build version, set by the main package at startup (injected via -ldflags). Defaults to "dev" for go test / go run builds.
Functions ¶
func AddHost ¶ added in v0.0.10
func AddHost(settings *Settings, host HostConfig) error
AddHost adds a new host to settings
func GetSettingsDir ¶ added in v0.0.10
GetSettingsDir returns the path to the settings directory
func GetSettingsPath ¶ added in v0.0.10
GetSettingsPath returns the path to the settings file
func HandleHostManagement ¶ added in v0.0.10
HandleHostManagement handles host management commands
func HandlePasswordManagement ¶
HandlePasswordManagement handles all password management operations.
func HandleTransfer ¶ added in v0.0.13
HandleTransfer performs a direct server-to-server file transfer. It opens SSH connections to both the source and destination hosts and streams data between them through the local machine without touching local disk.
func RemoveHost ¶ added in v0.0.10
RemoveHost removes a host from settings by name
func SaveSettings ¶ added in v0.0.10
SaveSettings saves settings to the settings file
func UpdateHost ¶ added in v0.0.10
func UpdateHost(settings *Settings, host HostConfig) error
UpdateHost updates an existing host configuration
func ValidateHostConfig ¶ added in v0.0.10
func ValidateHostConfig(host *HostConfig) error
ValidateHostConfig validates a host configuration
Types ¶
type ExitError ¶ added in v0.0.10
type ExitError struct {
Code int
}
ExitError carries a remote command's exit status so the process can exit with the same code (mirroring the behavior of the ssh client).
type HostConfig ¶ added in v0.0.10
type HostConfig struct {
Name string `json:"name"` // Host name (unique identifier)
Description string `json:"description,omitempty"` // Description
Host string `json:"host"` // IP or hostname
Port string `json:"port,omitempty"` // Port (default: 22)
User string `json:"user,omitempty"` // Username (default: master)
Key string `json:"key,omitempty"` // SSH private key path (optional, overrides global key)
PasswordKey string `json:"password_key,omitempty"` // Password key name (optional)
Type string `json:"type,omitempty"` // System type (linux/windows/macos)
}
HostConfig represents a configured host
func GetHost ¶ added in v0.0.10
func GetHost(settings *Settings, name string) (*HostConfig, error)
GetHost retrieves a host configuration by name
func ListHosts ¶ added in v0.0.10
func ListHosts(settings *Settings) []HostConfig
ListHosts returns all configured hosts
type Settings ¶ added in v0.0.10
type Settings struct {
Key string `json:"key,omitempty"` // Default SSH key path (e.g., ~/.ssh/id_rsa)
Hosts []HostConfig `json:"hosts"` // List of configured hosts
}
Settings represents the user-level configuration
func LoadSettings ¶ added in v0.0.10
LoadSettings loads settings from the settings file