lima-vm/lima · error

failed to enable SSHD: %w

Error message

failed to enable SSHD: %w

What it means

On macOS guests, fakecloudinit.Run mounts /Volumes/cidata and applies cloud-init-like metadata/user-data. If the enableSSHD step (turning on Remote Login / sshd) fails, the error is wrapped with this prefix and collected into the aggregate error. The VM's SSH access will not be available, so provisioning cannot proceed normally.

Source

Thrown at pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go:32

	"os/exec"
	"os/user"
	"path/filepath"
	"strconv"
	"strings"

	"github.com/goccy/go-yaml"
	"github.com/sethvargo/go-password/password"
	"github.com/sirupsen/logrus"

	"github.com/lima-vm/lima/v2/pkg/cidata/cloudinittypes"
	"github.com/lima-vm/lima/v2/pkg/osutil"
)

func Run(ctx context.Context) error {
	const mnt = "/Volumes/cidata"
	var errs []error
	if err := enableSSHD(ctx); err != nil {
		errs = append(errs, fmt.Errorf("failed to enable SSHD: %w", err))
	}
	if err := processMetaData(ctx, mnt); err != nil {
		errs = append(errs, fmt.Errorf("failed to process meta data: %w", err))
	}
	if err := processUserData(ctx, mnt); err != nil {
		errs = append(errs, fmt.Errorf("failed to process user data: %w", err))
	}
	if err := runBootScripts(ctx); err != nil {
		errs = append(errs, fmt.Errorf("failed to run boot scripts: %w", err))
	}
	return errors.Join(errs...)
}

func enableSSHD(ctx context.Context) error {
	cmd := exec.CommandContext(ctx, "/bin/launchctl", "load", "-w", "/System/Library/LaunchDaemons/ssh.plist")
	logrus.Infof("Executing command: %v", cmd.Args)
	if output, err := cmd.CombinedOutput(); err != nil {
		return fmt.Errorf("failed to execute command %v: %w (output=%#q)", cmd.Args, err, output)

View on GitHub (pinned to dd909d0973)

Solutions

  1. Unwrap the error (errors.Unwrap / %w chain) to see the underlying enableSSHD failure and fix that root cause.
  2. Ensure the provisioning code runs with sufficient privileges (root) inside the macOS guest.
  3. Verify sshd exists and Remote Login is permitted by the guest's configuration (MDM/security policies often disable it).
  4. Check that /Volumes/cidata is mounted correctly and the boot scripts run after the disk is available.
  5. Retry provisioning; early-boot timing issues can cause transient failures.
Defensive patterns

Strategy: try-catch

Try / catch

if err := fakecloudinit.Run(ctx); err != nil {
    var wrapped interface{ Unwrap() error }
    log.Errorf("provisioning failed: %v", err)
    // inspect the chain to find the underlying enableSSHD failure
    return fmt.Errorf("fakecloudinit provisioning failed: %w", err)
}

Prevention

When it happens

Trigger: Bootstrapping a macOS (darwin) guest whose cidata.iso provisioning runs enableSSHD and the underlying command (e.g. systemsetup/system configuration for Remote Login) returns an error — wrong privileges, missing binaries, or a guest OS that blocks the change.

Common situations: macOS VM images where sshd/Remote Login cannot be enabled: running without root/admin rights inside the guest, a hardened macOS configuration disabling remote login, or the provisioning script executing before the system is ready.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/071e0c6ec4dafb1b. Report an issue: GitHub.