Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SSHClient ¶
type SSHClient interface {
// Create creates a new SSH client
Create(user, host, keyPath string) (SSHClient, error)
// StartTunnel starts an SSH tunnel with port forwarding from local to remote
// It returns a function to stop the tunnel and an error if the tunnel fails to start
StartTunnel(ctx context.Context, localPort, remotePort string) (stop func() error, err error)
// Exec executes a command on the remote host
Exec(ctx context.Context, cmd string) (string, error)
// ExecFatal executes a command and returns error if it fails
ExecFatal(ctx context.Context, cmd string) string
// Uploads a local file to the remote host
Upload(ctx context.Context, localPath, remotePath string) error
// UploadPrivate uploads like Upload but sets remotePerm on the remote path via SFTP after create and before copying payload (reduces permission race on secrets).
UploadPrivate(ctx context.Context, localPath, remotePath string, remotePerm os.FileMode) error
// Close closes the SSH connection
Close() error
}
SSHClient provides SSH operations
func NewClientWithJumpHost ¶
func NewClientWithJumpHost(jumpUser, jumpHost, jumpKeyPath, targetUser, targetHost, targetKeyPath string) (SSHClient, error)
NewClientWithJumpHost creates a new SSH client that connects through a jump host It first connects to the jump host, then establishes a connection to the target host through it
type TunnelInfo ¶
TunnelInfo holds information about an established SSH tunnel
func EstablishSSHTunnel ¶
func EstablishSSHTunnel(ctx context.Context, sshClient SSHClient, remotePort string) (*TunnelInfo, error)
EstablishSSHTunnel establishes an SSH tunnel with port forwarding from remote node to local port on the client It automatically finds a free local port to avoid conflicts when running parallel tests. Uses retry logic for transient connection errors. Returns the tunnel info, local port and error if the tunnel fails to start
Click to show internal directories.
Click to hide internal directories.