Documentation
¶
Index ¶
- func Command(ssh *ssh.Client, cmd string) (string, error)
- func ForEachHost(hostConfigs []*Config, fn ExecuteFunc)
- func ForEachHostWithSFTP(hostConfigs []*Config, fn ExecuteWithSFTPFunc)
- func IsSymlink(sftpClient *sftp.Client, remotePath string) (bool, error)
- func Mkdir(sftpClient *sftp.Client, remotePath string) error
- func Open(cfg *Config) (*ssh.Client, error)
- func OpenSftp(client *ssh.Client) (*sftp.Client, error)
- func ReadLink(sftpClient *sftp.Client, remotePath string) (string, error)
- func RemoteExists(sftpClient *sftp.Client, remotePath string) bool
- func UploadFile(sftpClient *sftp.Client, localPath, remotePath string) error
- type Config
- type ExecuteFunc
- type ExecuteWithSFTPFunc
- type FileInfo
- type SFTPClient
- type SSHClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Command ¶
Command executes a command on the remote host and returns the output
func ForEachHost ¶
func ForEachHost(hostConfigs []*Config, fn ExecuteFunc)
ForEachHost iterates over all hosts and executes the given function with SSH connection It handles connection opening/closing and error logging automatically
func ForEachHostWithSFTP ¶
func ForEachHostWithSFTP(hostConfigs []*Config, fn ExecuteWithSFTPFunc)
ForEachHostWithSFTP iterates over all hosts and executes the given function with both SSH and SFTP connections It handles connection opening/closing and error logging automatically
func IsSymlink ¶
IsSymlink determines whether the remote path is a symbolic link
func Mkdir ¶
Mkdir creates a directory on the remote server, creating it if it doesn't exist
func ReadLink ¶
ReadLink reads the actual path that the remote symbolic link points to
func RemoteExists ¶
RemoteExists determines whether the remote path exists
Types ¶
type Config ¶
type Config struct {
User string `yaml:"user"` // Login username
Password string `yaml:"password"` // Password, optional
Host string `yaml:"host"` // Remote host address
Port int `yaml:"port"` // Port, default 22
KeyPath string `yaml:"keyPath"` // Private key path, optional
Passphrase string `yaml:"passphrase"` // Private key password, optional
Timeout time.Duration `yaml:"timeout"` // SSH connection timeout
}
Config SSH connection configuration
type ExecuteFunc ¶
ExecuteFunc defines a function that executes with an SSH client
type ExecuteWithSFTPFunc ¶
type ExecuteWithSFTPFunc func(*SFTPClient, *SSHClient, *Config) error
ExecuteWithSFTPFunc defines a function that executes with both SSH and SFTP clients
Source Files
¶
- load.go
- manager.go
- sftp.go
- ssh.go