ssh

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(mgr *Manager, host, user, keyPath, password string, port int) (string, error)

Connect establishes an SSH connection and stores the session. keyPath is the path to a PEM-encoded private key file. If password is provided and keyPath is empty, password auth is used.

Types

type InteractiveManager added in v1.0.5

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

InteractiveManager manages interactive SSH sessions.

func NewInteractiveManager added in v1.0.5

func NewInteractiveManager() *InteractiveManager

NewInteractiveManager creates a new interactive session manager.

func (*InteractiveManager) Close added in v1.0.5

func (im *InteractiveManager) Close(id string) error

Close terminates an interactive session.

func (*InteractiveManager) List added in v1.0.5

List returns information about all active interactive sessions.

func (*InteractiveManager) Open added in v1.0.5

func (im *InteractiveManager) Open(sshMgr *Manager, sshSessionID string, cols, rows int) (string, error)

Open starts an interactive SSH shell session with PTY allocation on an existing SSH connection managed by the given Manager.

func (*InteractiveManager) Resize added in v1.0.5

func (im *InteractiveManager) Resize(id string, cols, rows int) error

Resize changes the terminal dimensions for an interactive session.

func (*InteractiveManager) Send added in v1.0.5

func (im *InteractiveManager) Send(id, input string) error

Send writes input to the interactive session's stdin.

func (*InteractiveManager) Subscribe added in v1.0.5

func (im *InteractiveManager) Subscribe(id string) (<-chan []byte, func(), error)

Subscribe creates a channel that receives a copy of all output from the interactive session. Returns the read channel and an unsubscribe function.

type InteractiveSession added in v1.0.5

type InteractiveSession struct {
	ID           string
	SSHSessionID string
	// contains filtered or unexported fields
}

InteractiveSession wraps an SSH session with PTY allocation for interactive use.

type InteractiveSessionInfo added in v1.0.5

type InteractiveSessionInfo struct {
	ID           string `json:"id"`
	SSHSessionID string `json:"ssh_session_id"`
	Cols         int    `json:"cols"`
	Rows         int    `json:"rows"`
}

InteractiveSessionInfo holds metadata about an interactive SSH session.

type Manager

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

Manager manages active SSH sessions.

func NewManager

func NewManager() *Manager

NewManager creates a new SSH session manager.

func (*Manager) Disconnect

func (m *Manager) Disconnect(id string) error

Disconnect closes and removes an SSH session.

func (*Manager) Exec

func (m *Manager) Exec(id, command string) (string, error)

Exec runs a command on the remote server via the given session.

func (*Manager) Get

func (m *Manager) Get(id string) (*Session, error)

Get retrieves a session by ID.

func (*Manager) List

func (m *Manager) List() []SessionInfo

List returns info about all active sessions.

type Session

type Session struct {
	ID   string
	Host string
	User string
	Port int

	ConnectedAt time.Time
	// contains filtered or unexported fields
}

Session represents an active SSH connection.

func (*Session) Client

func (s *Session) Client() *ssh.Client

Client returns the underlying *ssh.Client for this session.

type SessionInfo

type SessionInfo struct {
	ID          string `json:"id"`
	Host        string `json:"host"`
	User        string `json:"user"`
	Port        int    `json:"port"`
	ConnectedAt string `json:"connected_at"`
}

SessionInfo is a read-only snapshot of a session for listing.

Jump to

Keyboard shortcuts

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