ssh

package
v0.0.0-...-81fcdeb Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ssh provides SSH connection management for cbwsh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostKeyCallback

func HostKeyCallback(knownHostsPath string) ssh.HostKeyCallback

HostKeyCallback returns a host key callback that checks known hosts. Deprecated: Use SetStrictHostKeyChecking and connect methods instead.

func ParseSSHURI

func ParseSSHURI(uri string) (user, host string, port int, err error)

ParseSSHURI parses an SSH URI into components.

Types

type Manager

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

Manager handles SSH connections and host management.

func NewManager

func NewManager(hostFilePath string, timeout time.Duration) *Manager

NewManager creates a new SSH manager.

func (*Manager) AddHostToKnownHosts

func (m *Manager) AddHostToKnownHosts(hostname string, remote net.Addr, key ssh.PublicKey) error

AddHostToKnownHosts adds a host key to the known_hosts file.

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context, host string, port int, user string) error

Connect establishes an SSH connection.

func (*Manager) ConnectToSavedHost

func (m *Manager) ConnectToSavedHost(ctx context.Context, name string) error

ConnectToSavedHost connects to a saved host by name.

func (*Manager) ConnectWithKey

func (m *Manager) ConnectWithKey(ctx context.Context, host string, port int, user, keyPath, passphrase string) error

ConnectWithKey establishes an SSH connection using a key file.

func (*Manager) ConnectWithPassword

func (m *Manager) ConnectWithPassword(ctx context.Context, host string, port int, user, password string) error

ConnectWithPassword establishes an SSH connection using password authentication.

func (*Manager) CurrentHost

func (m *Manager) CurrentHost() *core.SSHHost

CurrentHost returns the currently connected host.

func (*Manager) Disconnect

func (m *Manager) Disconnect() error

Disconnect closes the current SSH connection.

func (*Manager) Execute

func (m *Manager) Execute(ctx context.Context, command string) (*core.CommandResult, error)

Execute runs a command on the remote host.

func (*Manager) ForwardLocalPort

func (m *Manager) ForwardLocalPort(ctx context.Context, localPort int, remoteHost string, remotePort int) error

ForwardLocalPort creates a local port forwarding tunnel.

func (*Manager) IsHostKnown

func (m *Manager) IsHostKnown(hostname string) bool

IsHostKnown checks if a host is in the known_hosts file.

func (*Manager) ListSavedHosts

func (m *Manager) ListSavedHosts() ([]core.SSHHost, error)

ListSavedHosts returns a list of saved SSH hosts.

func (*Manager) RemoveHost

func (m *Manager) RemoveHost(name string) error

RemoveHost removes a saved SSH host.

func (*Manager) SaveHost

func (m *Manager) SaveHost(host core.SSHHost) error

SaveHost saves an SSH host configuration.

func (*Manager) SetKnownHostsPath

func (m *Manager) SetKnownHostsPath(path string)

SetKnownHostsPath sets the path to the known_hosts file.

func (*Manager) SetStrictHostKeyChecking

func (m *Manager) SetStrictHostKeyChecking(strict bool)

SetStrictHostKeyChecking enables or disables strict host key checking.

func (*Manager) State

func (m *Manager) State() core.SSHConnectionState

State returns the current connection state.

Jump to

Keyboard shortcuts

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