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
- func PortToString(port int) string
- type Client
- func (c *Client) Conn(ctx context.Context) (*ssh.Client, error)
- func (c *Client) Connect(ctx context.Context) (*ssh.Client, error)
- func (c *Client) DialFunc(ctx context.Context) (func(network, addr string) (net.Conn, error), *ssh.Client, error)
- func (c *Client) Download(ctx context.Context, remotePath, localPath string, recursive bool) error
- func (c *Client) Execute(ctx context.Context, cmd string, stdout, stderr io.Writer) error
- func (c *Client) Forward(ctx context.Context, localPort int, remoteHost string, remotePort int) (*Tunnel, error)
- func (c *Client) Host() string
- func (c *Client) Interactive(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Client) InteractiveCommand(ctx context.Context, cmd string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *Client) StartSession(ctx context.Context) (*Session, error)
- func (c *Client) Upload(ctx context.Context, localPath, remotePath string, recursive bool) error
- type Session
- type Tunnel
Constants ¶
const DefaultVMDomain = "vm.vers.sh"
DefaultVMDomain is the production VM domain suffix.
Variables ¶
This section is empty.
Functions ¶
func PortToString ¶
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
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
Conn returns a raw SSH connection for use with SFTP. Caller is responsible for closing the returned client.
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
Download copies a remote file or directory to the local 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) Interactive ¶ added in v0.5.4
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
StartSession creates a new session for streaming command execution.
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) Stdin ¶ added in v0.5.4
func (s *Session) Stdin() io.WriteCloser
Stdin returns the stdin writer.