machines

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package machines adds another machine to the session list (ADR-0024): it finds candidates, and it runs the one setup both `smif remote add` and the Machines screen use.

The password goes to ssh and sudo and nowhere else. The daemon never uses your own key: smif makes one that can only run `smif sessions --json` there.

Index

Constants

View Source
const (
	CommandLinux = "sudo apt install -y openssh-server && sudo systemctl enable --now ssh"
	CommandMac   = "sudo systemsetup -setremotelogin on"
)

The command to run on a machine with ssh off. smif cannot do this from here.

View Source
const AskpassEnv = "SMIF_ASKPASS"

AskpassEnv marks a run of the smif binary as ssh's askpass helper.

Variables

View Source
var ErrStopped = errors.New("stopped")

ErrStopped is a setup you stopped.

View Source
var Steps = []struct {
	ID    Step
	Label string
}{
	{StepReach, "Reach ssh"},
	{StepLogin, "Log in"},
	{StepSystem, "Detect the system"},
	{StepSmif, "Install smif"},
	{StepKey, "Add a key that can only list sessions"},
	{StepLinger, "Keep smif running after logout"},
	{StepConfig, "Add it to your list"},
	{StepDaemon, "Wait for your daemon to connect"},
}

Steps is the checklist in order.

Functions

func Askpass

func Askpass(sock string) int

Askpass is the helper: it prints the password for ssh and nothing else.

Types

type Asker

type Asker interface {
	// Closed says ssh does not answer on that machine. The setup keeps trying.
	Closed(name string)
	// Login asks for a password. problem is why it asks again, or empty.
	Login(user, problem string) (string, string, bool)
	// Sudo asks for the sudo password. problem is why it asks again, or empty.
	Sudo(problem string) (string, bool)
	// Install asks to install smif on that machine.
	Install() bool
}

Asker answers the questions only a person can. Each call blocks. False stops the setup, except Sudo, where false skips the step.

type Daemon

type Daemon interface {
	Reload() error
	// Reached reports the daemon's last look at a host.
	Reached(host string) (ok bool, detail string, err error)
}

Daemon is the running daemon, which must reach the machine by itself.

type Event

type Event struct {
	Step   Step
	State  State
	Detail string
}

Event says that a step changed.

type Found

type Found struct {
	Name   string // what the list shows
	Target string // what ssh connects to
	Source string // where smif saw it
	Open   bool   // port 22 (or its configured port) answers
	// contains filtered or unexported fields
}

Found is a machine you could add.

func Discover

func Discover(ctx context.Context, skip map[string]bool) []Found

Discover lists machines from ~/.ssh/config, Tailscale and the local network, and checks which ones answer. skip holds names you already added.

type Setup

type Setup struct {
	Host   string // an ssh alias or user@host
	Ask    Asker
	Report func(Event)
	Daemon Daemon
	// contains filtered or unexported fields
}

Setup adds one machine. Set Host, Ask, Report and Daemon.

func (*Setup) Run

func (s *Setup) Run(ctx context.Context) error

Run does the setup. A failed step has told Report why.

type State

type State int

State is where a step is.

const (
	Waiting State = iota
	Running
	Done
	Skipped
	Failed
)

type Step

type Step string

Step is one line of the checklist.

const (
	StepReach  Step = "reach"
	StepLogin  Step = "login"
	StepSystem Step = "system"
	StepSmif   Step = "smif"
	StepKey    Step = "key"
	StepLinger Step = "linger"
	StepConfig Step = "config"
	StepDaemon Step = "daemon"
)

Jump to

Keyboard shortcuts

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