sshfacade

package
v0.8.59 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package sshfacade implements the daemon-side SSH front door for islands. The daemon (dejimad) is the single SSH endpoint for every island: it authenticates the connection against the target island's authorized_keys, then bridges the SSH session into the container via `docker exec` (see server.go). Islands run no sshd and expose no ports — the daemon brokers access exactly as it does for the websocket/PTY path, so this works identically on Linux and macOS and keeps containment intact. The SSH *username* selects the island; the public key authorizes it.

Two key stores authorize a connection (their union):

  • per-island authorized_keys (~/.dejima/projects/<name>/ssh/authorized_keys) — grant a specific key access to one island (e.g. a collaborator).
  • the account allow-set (~/.dejima/ssh_authorized_keys) — keys that may ssh into *every* island, current and future. Register once (your laptop, your desktop) and all islands accept it with no per-island step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAccountKey

func AddAccountKey(line string) (string, error)

AddAccountKey appends a key to the account-wide allow-set — keys that may ssh into every island, current and future. Returns the key's fingerprint.

func AddAuthorizedKey

func AddAuthorizedKey(island, line string) (string, error)

AddAuthorizedKey validates an "ssh-… AAAA… [comment]" line and appends it to the island's authorized_keys (deduped). Returns the parsed key's fingerprint.

func Authorize

func Authorize(island string, offered ssh.PublicKey) (bool, error)

Authorize reports whether offered is allowed to ssh into island — true if the key is in the island's own authorized_keys OR in the account-wide allow-set. A missing file in either store simply contributes no keys. The island name is validated first (defense against a traversal in the SSH username).

func Fingerprint

func Fingerprint(signer ssh.Signer) string

Fingerprint returns the SHA256 fingerprint of a signer's public key, for the CLI to display so clients can pin the daemon's host key.

func HostSigner

func HostSigner() (ssh.Signer, error)

HostSigner returns the daemon's SSH host key, generating and persisting a fresh ed25519 key (0600) on first use. One host key for the daemon — it is the single SSH front door, so clients pin one identity regardless of island.

func RemoveAccountKey

func RemoveAccountKey(fingerprint string) (int, error)

RemoveAccountKey deletes the account key whose SHA256 fingerprint matches. Revoking here instantly removes fleet-wide access (no per-island cleanup).

func RemoveAllAccountKeys

func RemoveAllAccountKeys() (int, error)

RemoveAllAccountKeys clears the account-wide allow-set.

func RemoveAllAuthorizedKeys

func RemoveAllAuthorizedKeys(island string) (int, error)

RemoveAllAuthorizedKeys clears every authorized key for the island.

func RemoveAuthorizedKey

func RemoveAuthorizedKey(island, fingerprint string) (int, error)

RemoveAuthorizedKey deletes the island key whose SHA256 fingerprint matches. Returns how many were removed (0 if no match).

Types

type KeyInfo

type KeyInfo struct {
	Fingerprint string // SHA256:…
	Type        string // e.g. ssh-ed25519
	Comment     string
}

KeyInfo is one authorized public key, for display.

func ListAccountKeys

func ListAccountKeys() ([]KeyInfo, error)

ListAccountKeys returns the account-wide keys in file order.

func ListAuthorizedKeys

func ListAuthorizedKeys(island string) ([]KeyInfo, error)

ListAuthorizedKeys returns the island's authorized keys in file order.

type Server

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

Server is the daemon-side SSH front door. It authenticates each connection's public key against the target island (the SSH *username* names the island), then bridges the session channel into the container with `docker exec` — reusing the same brokered-access model as the websocket/PTY path. Islands run no sshd; the daemon is the single audited endpoint.

func NewServer

func NewServer(log *slog.Logger) (*Server, error)

NewServer loads (or generates) the daemon host key and returns a ready Server.

func (*Server) HostKeyFingerprint

func (s *Server) HostKeyFingerprint() string

HostKeyFingerprint returns the SHA256 fingerprint of the daemon's host key, so the CLI can print it for clients to pin (known_hosts).

func (*Server) HostPublicKey added in v0.8.43

func (s *Server) HostPublicKey() string

HostPublicKey returns the daemon's host key as an OpenSSH authorized-key line ("ssh-ed25519 AAAA…"), so a client can pin it in a known_hosts entry it manages itself — fetched over the already-authenticated API, so a rotated key self-heals instead of tripping "REMOTE HOST IDENTIFICATION HAS CHANGED".

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve accepts connections until ln errors or is closed. Each connection is handled in its own goroutine.

Jump to

Keyboard shortcuts

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