ssh

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

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

type Connection struct {
	Client *ssh.Client
}

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) Close

func (c *Connection) Close() error

Close closes the SSH connection.

func (*Connection) Run

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.

Jump to

Keyboard shortcuts

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