Documentation
¶
Index ¶
- func CopyFileToRemoteScp(client *ssh.Client, src, rDir, rName string, permission uint32) error
- func GetParentDir(path string) string
- func ParsePublicKeyFromAny(keyData []byte) (ssh.PublicKey, error)
- type Client
- func (c *Client) AllowAllInbound() error
- func (c *Client) AppendToFile(path, content string, sudo bool) error
- func (c *Client) Close() error
- func (c *Client) ClosePort(port uint32, protocol string) error
- func (c *Client) ClosePorts(ports []uint32, protocol string) error
- func (c *Client) CombinedOutput(command string, sudo bool) (string, error)
- func (c *Client) CommandExists(command string, sudo bool) (bool, error)
- func (c *Client) CopyContentToRemote(src io.Reader, dst string, permission uint32) error
- func (c *Client) CopyContentToRemoteSudo(src io.Reader, dst string, permission uint32) error
- func (c *Client) CopyFileToRemoteSftp(src, dst string, permission uint32) error
- func (c *Client) CopyFileToRemoteSftpSudo(src, dst string, permission uint32) error
- func (c *Client) CreateDir(path string, sudo bool) error
- func (c *Client) DeletePortRule(port uint32, protocol string) error
- func (c *Client) DeletePortRules(ports []uint32, protocol string) error
- func (c *Client) DetectFirewall() (FirewallType, error)
- func (c *Client) DirExist(path string) (bool, error)
- func (c *Client) DisableFirewall() error
- func (c *Client) Download(output, url string, sudo bool) error
- func (c *Client) DownloadRemoteFileToLocal(remotePath, localPath string) error
- func (c *Client) DownloadRemoteFileToMemory(remotePath string) ([]byte, error)
- func (c *Client) EnableBbr() error
- func (c *Client) EnableFirewall() error
- func (c *Client) FileExisted(path string) (bool, error)
- func (c *Client) GetFirewallStatus() (string, error)
- func (c *Client) GetOSArch() (os string, arch string, err error)
- func (c *Client) GetServerOS() (string, error)
- func (c *Client) GetSftpClient() (*sftp.Client, error)
- func (c *Client) OpenPort(port uint32, protocol string) error
- func (c *Client) OpenPorts(ports []uint32, protocol string) error
- func (c *Client) Output(command string, sudo bool) (string, error)
- func (c *Client) PackageManager() (string, error)
- func (c *Client) PathExisted(path string) (bool, error)
- func (c *Client) Reboot() error
- func (c *Client) Run(command string, sudo bool) error
- func (c *Client) ServiceStatus(name string) (*ServiceStatus, error)
- func (c *Client) ShRun(command string, sudo bool) error
- func (c *Client) Shutdown() error
- func (c *Client) StdOutAndStdErr(command string, sudo bool) (string, string, error)
- func (c *Client) Suspend() error
- type DialConfig
- type FirewallType
- type ServiceStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFileToRemoteScp ¶
src is the local file path, rDir is the remote directory path, rName is the remote file name.
func GetParentDir ¶
GetParentDir returns the parent directory of a Unix-style path
Types ¶
type Client ¶
type Client struct {
*ssh.Client
Password string
sync.Mutex
// contains filtered or unexported fields
}
func (*Client) AllowAllInbound ¶
AllowAllInbound sets the firewall to allow all inbound connections WARNING: This is insecure and should only be used for testing
func (*Client) ClosePort ¶
ClosePort denies/blocks inbound traffic to a specific port with the given protocol (tcp/udp)
func (*Client) ClosePorts ¶
ClosePorts closes multiple ports for the given protocol (tcp/udp) This is a bulk operation that calls ClosePort for each port
func (*Client) CombinedOutput ¶
Returns output and error
func (*Client) CommandExists ¶
func (*Client) CopyContentToRemote ¶
func (*Client) CopyContentToRemoteSudo ¶
func (*Client) CopyFileToRemoteSftp ¶
src is the local file path, dst is the remote file path. permision is fs.FileMode if dst file already exists, it will be overwritten.
func (*Client) CopyFileToRemoteSftpSudo ¶
copy file to tmp folder, then move to dst using sudo
func (*Client) DeletePortRule ¶
DeletePortRule removes a firewall rule for a specific port This operation is idempotent - it won't error if the rule doesn't exist
func (*Client) DeletePortRules ¶
DeletePortRules deletes firewall rules for multiple ports This is a bulk operation that calls DeletePortRule for each port
func (*Client) DetectFirewall ¶
func (c *Client) DetectFirewall() (FirewallType, error)
DetectFirewall determines which firewall system is active on the remote server
func (*Client) DisableFirewall ¶
DisableFirewall disables the firewall service
func (*Client) Download ¶
download file from url to output using curl if path existed, it will be replaced by the new file
func (*Client) DownloadRemoteFileToLocal ¶
func (*Client) DownloadRemoteFileToMemory ¶ added in v1.0.1
func (*Client) EnableFirewall ¶
EnableFirewall enables the firewall service
func (*Client) GetFirewallStatus ¶
GetFirewallStatus returns the firewall status and rules
func (*Client) GetServerOS ¶
func (*Client) OpenPort ¶
OpenPort allows inbound traffic to a specific port with the given protocol (tcp/udp) This operation is idempotent - it checks if the rule already exists before adding
func (*Client) OpenPorts ¶
OpenPorts opens multiple ports for the given protocol (tcp/udp) This is a bulk operation that calls OpenPort for each port
func (*Client) PackageManager ¶
func (*Client) ServiceStatus ¶
func (c *Client) ServiceStatus(name string) (*ServiceStatus, error)
func (*Client) ShRun ¶
client.CombinedOutput("sh -c 'curl -fsSL https://get.docker.com | sh'", true)
func (*Client) StdOutAndStdErr ¶
Returns error
type DialConfig ¶
type FirewallType ¶
type FirewallType string
FirewallType represents the type of firewall system
const ( FirewallUFW FirewallType = "ufw" FirewallFirewalld FirewallType = "firewalld" FirewallIptables FirewallType = "iptables" FirewallNftables FirewallType = "nftables" FirewallUnknown FirewallType = "unknown" )