ssh

package
v0.0.0-...-cb3f3e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupSSHKeys

func CleanupSSHKeys(clusterName string) error

CleanupSSHKeys removes SSH keys for a cluster

Types

type Client

type Client struct {
	Host     string
	Port     string
	User     string
	Password string
	PrivKey  string
	// contains filtered or unexported fields
}

Client is a wrapper for the SSH client

func NewClient

func NewClient(host, port, user, password, privKey string) *Client

NewClient creates a new SSH client

func (*Client) Close

func (c *Client) Close() error

Close closes the SSH connection

func (*Client) Connect

func (c *Client) Connect() error

Connect connects to the SSH server

func (*Client) DownloadFile

func (c *Client) DownloadFile(remotePath, localPath string) error

DownloadFile downloads a file from the remote server using SFTP protocol

func (*Client) RunCommand

func (c *Client) RunCommand(command string) (string, error)

RunCommand runs a command on the SSH server, with retry mechanism

func (*Client) UploadDirectory

func (c *Client) UploadDirectory(localDirPath, remoteDirPath string) error

UploadDirectory uploads a local directory to the remote server using SFTP protocol

func (*Client) UploadFile

func (c *Client) UploadFile(localPath, remotePath string) error

UploadFile uploads a local file to the remote server using SFTP protocol

type SSHConfig

type SSHConfig struct {
	Password      string
	SSHKeyFile    string
	SSHPubKeyFile string
	// contains filtered or unexported fields
}

func NewSSHConfig

func NewSSHConfig(password string, clusterName string) (*SSHConfig, error)

NewSSHConfig creates a new SSH configuration with auto-generated keys for the cluster

func NewSSHConfigWithKeys

func NewSSHConfigWithKeys(password string, sshKeyFile string, sshPubKeyFile string) (*SSHConfig, error)

NewSSHConfigWithKeys creates SSH configuration with provided key file paths (for backward compatibility)

func (*SSHConfig) GetSSHKey

func (c *SSHConfig) GetSSHKey() string

func (*SSHConfig) GetSSHPubKey

func (c *SSHConfig) GetSSHPubKey() string

type SSHManager

type SSHManager struct {
	// contains filtered or unexported fields
}

SSHManager manages SSH clients and their lifecycle

func NewSSHManager

func NewSSHManager(cluster *config.Cluster, sshConfig *SSHConfig) *SSHManager

NewSSHManager creates a new SSH manager

func (*SSHManager) Address

func (sm *SSHManager) Address(nodeName string) string

func (*SSHManager) Close

func (sm *SSHManager) Close() error

CloseAllClients closes all SSH clients

func (*SSHManager) CloseClient

func (sm *SSHManager) CloseClient(nodeName string)

CloseClient closes the SSH client for the specified node

func (*SSHManager) CreateClient

func (sm *SSHManager) CreateClient(nodeName string, ip string) (*Client, error)

func (*SSHManager) DownloadFile

func (sm *SSHManager) DownloadFile(nodeName, remotePath, localPath string) error

DownloadFile downloads a file from a remote node to local path using proper SCP protocol

func (*SSHManager) GetClient

func (sm *SSHManager) GetClient(nodeName string) (*Client, bool)

GetClient gets an SSH client

func (*SSHManager) GetSSHConfig

func (sm *SSHManager) GetSSHConfig() *SSHConfig

GetSSHConfig returns the SSH configuration

func (*SSHManager) RunCommand

func (sm *SSHManager) RunCommand(nodeName, command string) (string, error)

RunCommand executes a command on the specified node

func (*SSHManager) StartHealthCheck

func (sm *SSHManager) StartHealthCheck()

StartHealthCheck starts the health check for SSH connections

func (*SSHManager) StopHealthCheck

func (sm *SSHManager) StopHealthCheck()

StopHealthCheck stops the health check

func (*SSHManager) TransferFile

func (sm *SSHManager) TransferFile(nodeName, localPath, remotePath string) error

TransferFile implements the SSHFileTransfer interface (for backward compatibility)

func (*SSHManager) UploadDirectory

func (sm *SSHManager) UploadDirectory(nodeName, localDirPath, remoteDirPath string) error

UploadDirectory uploads a local directory to a remote node using proper SFTP protocol

func (*SSHManager) UploadFile

func (sm *SSHManager) UploadFile(nodeName, localPath, remotePath string) error

UploadFile uploads a local file to a remote node using proper SCP protocol

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址