sshx

package
v0.2026195.1833 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialSSH

func DialSSH(t vmshared.SSHTarget) (*ssh.Client, error)

DialSSH opens an authenticated SSH client connection to the target. Caller must Close.

func SSHAuthMethods

func SSHAuthMethods() ([]ssh.AuthMethod, error)

SSHAuthMethods probes the user's environment for usable SSH auth. Agent first, then the three common Ed25519/RSA/ECDSA private keys.

func SSHClientConfig

func SSHClientConfig(t vmshared.SSHTarget) (*ssh.ClientConfig, error)

SSHClientConfig builds an *ssh.ClientConfig for the given target using (in order):

  • SSH_AUTH_SOCK — ssh-agent keys, if available.
  • ~/.ssh/id_ed25519, ~/.ssh/id_rsa, ~/.ssh/id_ecdsa — any readable key file (unencrypted; we don't prompt for passphrases here — the user's normal workflow should keep keys in the agent).

Host-key checking honors ~/.ssh/known_hosts when present; otherwise it falls back to InsecureIgnoreHostKey. Callers that need strict verification should ensure the agent path is available.

Types

type SSHTunnel

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

SSHTunnel is a live SSH connection plus any forwards opened against it. Call Close to tear everything down.

func NewSSHTunnel

func NewSSHTunnel(t vmshared.SSHTarget) (*SSHTunnel, error)

NewSSHTunnel dials the target and returns a tunnel handle. The underlying ssh.Client can host any number of forwards.

func (*SSHTunnel) Client

func (t *SSHTunnel) Client() *ssh.Client

Client returns the underlying SSH client, for consumers that open their own channels over the same connection (e.g. dialing a remote unix socket). The client stays owned by the tunnel — use Close to disconnect.

func (*SSHTunnel) Close

func (t *SSHTunnel) Close() error

Close tears down all open forwards, then disconnects. Idempotent.

func (*SSHTunnel) ForwardTCP

func (t *SSHTunnel) ForwardTCP(ctx context.Context, remoteHost string, remotePort int) (string, func(), error)

ForwardTCP opens a local 127.0.0.1:<random> listener that forwards each accepted connection to <remoteHost>:<remotePort> via the SSH connection. Returns the local "127.0.0.1:<port>" address plus a cleanup func that closes the listener (but not the SSH client — use Close for that).

func (*SSHTunnel) ForwardUnix

func (t *SSHTunnel) ForwardUnix(ctx context.Context, remoteSocket string) (string, func(), error)

ForwardUnix opens a local UNIX socket under /tmp/charly-tunnel-<uuid>.sock that forwards each accepted connection to <remoteSocket> on the other side of the SSH connection. Returns the local socket path plus a cleanup func.

Jump to

Keyboard shortcuts

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