Documentation
¶
Index ¶
- func AllHosts() (string, error)
- func EnsureDir() error
- func FindHost(query string) (*Host, []Host, error)
- func GenerateKeyPair(name, keyType string, bits int) (pubPath, privPath string, err error)
- func RemoveHost(name string) error
- func SaveHost(host Host) error
- type Client
- func (c *Client) Close() error
- func (c *Client) Exec(command string) (stdout, stderr string, err error)
- func (c *Client) ExecStream(command string, onOutput func(line string, isStderr bool)) error
- func (c *Client) InteractiveSession(stdin io.Reader, stdout, stderr io.Writer, termWidth, termHeight int) error
- type Host
- type HostsFile
- type LogEntry
- type Store
- type TransferConfig
- type TransferLogEntry
- type TransferMethod
- type TransferResult
- func DownloadDir(client *Client, remoteDir, localDir string, preserve bool) ([]TransferResult, error)
- func DownloadFile(client *Client, remotePath, localPath string, preserve bool) (*TransferResult, error)
- func DownloadFileSCP(client *Client, remotePath, localPath string, preserve bool) (*TransferResult, error)
- func UploadDir(client *Client, localDir, remoteDir string, preserve bool) ([]TransferResult, error)
- func UploadFile(client *Client, localPath, remotePath string, preserve bool) (*TransferResult, error)
- func UploadFileSCP(client *Client, localPath, remotePath string, preserve bool) (*TransferResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindHost ¶
FindHost searches for a host by partial/fuzzy name match. It returns exact match first, then substring match, then address match.
func GenerateKeyPair ¶
GenerateKeyPair creates an SSH key pair and saves it to ~/.smara/ssh/keys/.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps an SSH client connection.
func (*Client) ExecStream ¶
ExecStream runs a command and streams output through a callback.
type Host ¶
type Host struct {
Name string `yaml:"name"`
Address string `yaml:"address"`
Port string `yaml:"port,omitempty"`
User string `yaml:"user"`
KeyPath string `yaml:"key_path,omitempty"`
Password string `yaml:"password,omitempty"`
}
Host represents a saved SSH host configuration.
type HostsFile ¶
type HostsFile struct {
Hosts []Host `yaml:"hosts"`
}
HostsFile is the top-level YAML structure.
type LogEntry ¶
type LogEntry struct {
ID int64 `json:"id"`
HostName string `json:"host_name"`
Address string `json:"address"`
Command string `json:"command"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Status string `json:"status"` // success / error
Duration int64 `json:"duration_ms"`
CreatedAt time.Time `json:"created_at"`
}
LogEntry represents a single SSH execution log.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides SQLite persistence for SSH logs.
func (*Store) ListTransferLogs ¶ added in v1.13.0
func (s *Store) ListTransferLogs(limit int) ([]TransferLogEntry, error)
ListTransferLogs returns recent SSH file transfer logs.
func (*Store) SaveTransferLog ¶ added in v1.13.0
func (s *Store) SaveTransferLog(entry TransferLogEntry) error
SaveTransferLog inserts a file transfer log entry.
type TransferConfig ¶ added in v1.13.0
type TransferConfig struct {
Method TransferMethod
Recursive bool
PreservePerms bool
}
TransferConfig holds options for upload/download operations.
type TransferLogEntry ¶ added in v1.13.0
type TransferLogEntry struct {
ID int64 `json:"id"`
HostName string `json:"host_name"`
Address string `json:"address"`
LocalPath string `json:"local_path"`
RemotePath string `json:"remote_path"`
Direction string `json:"direction"` // upload / download
Bytes int64 `json:"bytes"`
Method string `json:"method"` // sftp / scp
Status string `json:"status"` // success / error
ErrorMsg string `json:"error_msg"`
Duration int64 `json:"duration_ms"`
CreatedAt time.Time `json:"created_at"`
}
TransferLogEntry represents a single file transfer log.
type TransferMethod ¶ added in v1.13.0
type TransferMethod string
TransferMethod defines the protocol used for file transfer.
const ( TransferMethodAuto TransferMethod = "auto" TransferMethodSFTP TransferMethod = "sftp" TransferMethodSCP TransferMethod = "scp" )
type TransferResult ¶ added in v1.13.0
type TransferResult struct {
LocalPath string
RemotePath string
Direction string // upload / download
Bytes int64
Duration time.Duration
Status string // success / error
Error error
}
TransferResult summarizes a file transfer operation.
func DownloadDir ¶ added in v1.13.0
func DownloadDir(client *Client, remoteDir, localDir string, preserve bool) ([]TransferResult, error)
DownloadDir recursively downloads a directory via SFTP.
func DownloadFile ¶ added in v1.13.0
func DownloadFile(client *Client, remotePath, localPath string, preserve bool) (*TransferResult, error)
DownloadFile downloads a single file via SFTP.
func DownloadFileSCP ¶ added in v1.13.0
func DownloadFileSCP(client *Client, remotePath, localPath string, preserve bool) (*TransferResult, error)
SCP single-file download using ssh channel (scp -f).
func UploadDir ¶ added in v1.13.0
func UploadDir(client *Client, localDir, remoteDir string, preserve bool) ([]TransferResult, error)
UploadDir recursively uploads a directory via SFTP.
func UploadFile ¶ added in v1.13.0
func UploadFile(client *Client, localPath, remotePath string, preserve bool) (*TransferResult, error)
UploadFile uploads a single file via SFTP.
func UploadFileSCP ¶ added in v1.13.0
func UploadFileSCP(client *Client, localPath, remotePath string, preserve bool) (*TransferResult, error)
SCP single-file upload using ssh channel (scp -t).