Documentation
¶
Overview ¶
Package ssh offers utilities for creating and managing SSH (Secure Shell) connections, enabling secure communication with Windows operating systems. It allows executing commands on remote hosts securely and efficiently.
Key Features:
- Establishes SSH connections with remote hosts based on provided configuration.
- Handles authentication mechanisms such as password-based and privatekey-based authentication.
- Supports execution of commands including cmd and powershell commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string Port int Username string Password string PrivateKey string PrivateKeyPath string KnownHostsPath string Insecure bool }
Config represents the configuration details for establishing an SSH connection.
type Connection ¶
Connection represents an SSH connection. It holds a client object for interacting with the remote system.
func NewConnection ¶
func NewConnection(config *Config) (*Connection, error)
NewConnection creates a new SSH client based on the provided configuration.
func (*Connection) Run ¶
func (c *Connection) Run(ctx context.Context, cmd string) (connection.CmdResult, error)
Run runs a command using the configured SSH connection and context. It returns the result of the command execution, including stdout and stderr.
func (*Connection) RunWithPowershell ¶
func (c *Connection) RunWithPowershell(ctx context.Context, cmd string) (connection.CmdResult, error)
RunWithPowershell runs a command using the configured SSH connection and context via Powershell.