ssh

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ssh provides native SSH connectivity over TLS for vers VMs.

This package implements SSH-over-TLS tunneling where SSH connections are established through a TLS connection on port 443. VMs are accessed via DNS hostnames in the format {vm-id}.{vmDomain} (e.g. {vm-id}.vm.vers.sh).

Index

Constants

View Source
const DefaultVMDomain = "vm.vers.sh"

DefaultVMDomain is the production VM domain suffix.

Variables

This section is empty.

Functions

func PortToString

func PortToString(port int) string

PortToString converts a port number to string for compatibility.

Types

type Client added in v0.5.4

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

Client provides native SSH connectivity over TLS.

func NewClient added in v0.5.4

func NewClient(host, keyPath string, vmDomain ...string) *Client

NewClient creates a new SSH client for the given VM. Optional vmDomain overrides the default "vm.vers.sh" suffix.

func (*Client) Conn added in v0.5.4

func (c *Client) Conn(ctx context.Context) (*ssh.Client, error)

Conn returns a raw SSH connection for use with SFTP. Caller is responsible for closing the returned client.

func (*Client) Connect added in v0.5.4

func (c *Client) Connect(ctx context.Context) (*ssh.Client, error)

Connect establishes an SSH connection over TLS.

func (*Client) DialFunc added in v0.5.4

func (c *Client) DialFunc(ctx context.Context) (func(network, addr string) (net.Conn, error), *ssh.Client, error)

DialFunc returns a function that dials through the SSH connection. This can be used for port forwarding or other tunneling needs.

func (*Client) Download added in v0.5.4

func (c *Client) Download(ctx context.Context, remotePath, localPath string, recursive bool) error

Download copies a remote file or directory to the local host.

func (*Client) Execute added in v0.5.4

func (c *Client) Execute(ctx context.Context, cmd string, stdout, stderr io.Writer) error

Execute runs a command on the remote host.

func (*Client) Forward added in v0.6.0

func (c *Client) Forward(ctx context.Context, localPort int, remoteHost string, remotePort int) (*Tunnel, error)

Forward sets up local port forwarding: it listens on localPort and forwards connections through the SSH tunnel to remoteHost:remotePort on the VM. This is equivalent to `ssh -L localPort:remoteHost:remotePort`.

If localPort is 0, the OS picks an available port (accessible via Tunnel.LocalPort). The returned Tunnel stays open until ctx is cancelled or Close() is called.

func (*Client) Host added in v0.5.5

func (c *Client) Host() string

Host returns the host identifier (VM ID).

func (*Client) Interactive added in v0.5.4

func (c *Client) Interactive(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error

Interactive runs an interactive shell session with PTY support.

func (*Client) InteractiveCommand added in v0.5.5

func (c *Client) InteractiveCommand(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) error

InteractiveCommand runs a command interactively with PTY support.

func (*Client) StartSession added in v0.5.4

func (c *Client) StartSession(ctx context.Context) (*Session, error)

StartSession creates a new session for streaming command execution.

func (*Client) Upload added in v0.5.4

func (c *Client) Upload(ctx context.Context, localPath, remotePath string, recursive bool) error

Upload copies a local file or directory to the remote host.

type Session added in v0.5.4

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

Session represents an active SSH session that can be used for streaming.

func (*Session) Close added in v0.5.4

func (s *Session) Close() error

Close closes the session and underlying connection.

func (*Session) Start added in v0.5.4

func (s *Session) Start(cmd string) error

Start starts a command without waiting for it to complete.

func (*Session) Stderr added in v0.5.4

func (s *Session) Stderr() io.Reader

Stderr returns the stderr reader.

func (*Session) Stdin added in v0.5.4

func (s *Session) Stdin() io.WriteCloser

Stdin returns the stdin writer.

func (*Session) Stdout added in v0.5.4

func (s *Session) Stdout() io.Reader

Stdout returns the stdout reader.

func (*Session) Wait added in v0.5.4

func (s *Session) Wait() error

Wait waits for the command to complete.

type Tunnel added in v0.6.0

type Tunnel struct {
	LocalPort  int
	RemoteHost string
	RemotePort int
	// contains filtered or unexported fields
}

Tunnel represents an active SSH port-forwarding tunnel.

func (*Tunnel) Close added in v0.6.0

func (t *Tunnel) Close()

Close stops the tunnel, closing the listener and all forwarded connections.

Jump to

Keyboard shortcuts

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