Help us shape the future of Go! Take the 2026 Go Developer Survey

clisshd

package
v1.3.97 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package clisshd cmd/skywire-cli/commands/sshd/sshd.go c4-vis-cli sshd`, the OpenSSH-equivalent server over skywire identity. Thin wrapper around pty.Host's direct-TCP entry point (PR #2559) with sensible defaults for the standalone-daemon shape:

  • TCP-only: no dmsg.Client, no dmsg listener (the visor or the standalone dmsgpty-host already handle the overlay path; sshd is for the direct-TCP case operators reach for ssh-style).
  • Identity defaulted to the local visor's SK so operators don't manage a separate keypair; --sk-from-visor accepts an explicit path, otherwise the default skywire-config.json is read.
  • Whitelist read from the dmsgpty config or supplied inline with --allow <pk>,<pk>; same data shape as authorized_keys.

For dual-mode (dmsg + TCP) operators, use the visor's embedded Dmsgpty.SshListen or the lower-level `dmsgpty-host` binary directly. This command is intentionally narrow.

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "sshd",
	Short: "Run a direct-TCP pty-subsystem server (peers connect by PK)",
	Long: `skywire cli pty host — OpenSSH-equivalent server over skywire identity.

Binds a TCP port and serves the dmsgpty protocol over it, gated by an
XK noise handshake against this server's PK + a whitelist of client
PKs. The protocol underneath is identical to the dmsg-overlay
dmsgpty-host; sshd is the discoverable, ssh-shaped surface over the
direct-TCP entry point.

Use this when:
  - You want a peer-to-peer remote shell that doesn't require running
    a full skywire visor on the server (or that runs ALONGSIDE one,
    sharing the visor's PK without contending for the dmsg-disc entry).
  - You have direct IP reachability to the server and want lower
    latency than the dmsg overlay path.
  - You're scripting ssh-like access into your skywire fleet.

Use the visor's embedded pty.ssh_listen field instead when:
  - You want the same port served by your already-running visor.
  - You want the dmsg-overlay path AND the TCP path on the same
    process (sshd is TCP-only by design).

Examples:
  # Run on :2022 with two PKs allowed, identity from default visor config:
  skywire cli pty host --listen :2022 --allow 02f9...,03d1...

  # Use a non-default visor config for the server identity:
  skywire cli pty host --listen :2022 --sk-from-visor /etc/skywire/skywire.json --allow 02f9...

  # Use a standalone dmsgpty config.json for both identity AND whitelist:
  skywire cli pty host --listen :2022 --conf /etc/skywire/pty.json`,
	SilenceErrors:         true,
	SilenceUsage:          true,
	DisableSuggestions:    true,
	DisableFlagsInUseLine: true,
	RunE: func(cmd *cobra.Command, _ []string) error {
		if sshdListen == "" {
			return fmt.Errorf("pty host: --listen is required")
		}

		log := logging.MustGetLogger("sshd")
		if lvl, err := logging.LevelFromString(sshdLog); err == nil {
			logging.SetLevel(lvl)
		}

		sk, err := resolveServerSK(sshdConfPath, sshdSKFromConf)
		if err != nil {
			return err
		}
		pk, err := sk.PubKey()
		if err != nil {
			return fmt.Errorf("pty host: derive PK from SK: %w", err)
		}

		wl, wlSize, err := buildSshdWhitelist(sshdConfPath, sshdAllow)
		if err != nil {
			return err
		}

		host := pty.NewHost(nil, wl)

		ctx, cancel := cmdutil.SignalContext(context.Background(), log)
		defer cancel()

		log.WithField("addr", sshdListen).
			WithField("pk", pk.String()).
			WithField("whitelist_size", wlSize).
			Info("pty host: listening")

		var wg sync.WaitGroup
		wg.Add(1)
		errCh := make(chan error, 1)
		go func() {
			defer wg.Done()
			errCh <- host.ListenAndServeTCP(ctx, sshdListen, pk, sk)
		}()

		select {
		case <-ctx.Done():
			log.Info("pty host: shutting down on signal")
		case err := <-errCh:
			if err != nil {
				return fmt.Errorf("pty host: listen %s: %w", sshdListen, err)
			}
		}
		wg.Wait()
		return nil
	},
}

RootCmd is `skywire cli pty host` — OpenSSH-equivalent server.

Registered under skywire-cli's root alongside `cli pty shell` (client). Compared to OpenSSH's sshd:

sshd_config Port      ↔ --listen
authorized_keys       ↔ --allow / --conf's whitelist
host key              ↔ --sk-from-visor (or the default visor SK)
HostbasedAuthentication ↔ noise XK pins both sides via PK

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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