Documentation ¶
Overview ¶
Package ssh implements the ssh client.
Index ¶
- Constants
- func SudoPrefix(cmd string) string
- type Client
- func (c *Client) Close()
- func (c *Client) Cmd(cmd string) (string, error)
- func (c *Client) Cmdf(cmd string, a ...any) (string, error)
- func (c *Client) Connect() error
- func (c *Client) ConnectSftpClient(opts ...sftp.ClientOption) error
- func (c *Client) Copy(src, dst string) error
- func (c *Client) Fetch(local, remote string) error
- func (c *Client) Fs() filesystem.Interface
- func (c *Client) Host() string
- func (c *Client) Ping() error
- func (c *Client) RemoteFileExist(remote string) (bool, error)
- func (c *Client) SudoCmd(cmd string) (string, error)
- func (c *Client) SudoCmdf(cmd string, a ...any) (string, error)
- type Command
- type Connector
- type Interface
- type LocalFileSystem
- type Sftp
Constants ¶
View Source
const ( DefaultSSHPort = 22 DefaultTimeout = 15 ROOT = "root" )
Default values.
Variables ¶
This section is empty.
Functions ¶
func SudoPrefix ¶
SudoPrefix returns the prefix for sudo commands.
Types ¶
type Client ¶
Client is a wrapper around the SSH client that provides a few helper.
func (*Client) Close ¶
func (c *Client) Close()
Close closes the underlying ssh and sftp connection.
func (*Client) ConnectSftpClient ¶
func (c *Client) ConnectSftpClient(opts ...sftp.ClientOption) error
ConnectSftpClient connects to the host sftp client using the provided ssh information.
func (*Client) Fs ¶
func (c *Client) Fs() filesystem.Interface
Fs returns the filesystem of the ssh client.
func (*Client) RemoteFileExist ¶
RemoteFileExist checks if a file exists on the remote host.
type Command ¶
type Command interface { Cmd(cmd string) (string, error) Cmdf(cmd string, a ...any) (string, error) SudoCmd(cmd string) (string, error) SudoCmdf(cmd string, a ...any) (string, error) }
Command collects the methods for executing commands.
type Connector ¶
type Connector interface { Connect() error Close() }
Connector collects the methods for connecting and closing.
type LocalFileSystem ¶
type LocalFileSystem interface {
Fs() filesystem.Interface
}
LocalFileSystem collects the methods for return a local filesystem.
Click to show internal directories.
Click to hide internal directories.