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
- Unwrap the error (errors.Unwrap / %w chain) to see the underlying enableSSHD failure and fix that root cause.
- Ensure the provisioning code runs with sufficient privileges (root) inside the macOS guest.
- Verify sshd exists and Remote Login is permitted by the guest's configuration (MDM/security policies often disable it).
- Check that /Volumes/cidata is mounted correctly and the boot scripts run after the disk is available.
- 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
- Run guest provisioning as root inside the macOS VM
- Verify /Volumes/cidata is mounted before calling Run
- Unwrap error chains to reach the enableSSHD root cause
- Confirm the guest image permits Remote Login (no MDM lock)
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
- failed to write password file for user %#q: %w
- failed to write sudoers file for user %#q: %w
- unable to connect to guest agent via vsock port 2222
- failed to mount fstab entry %v: %w
- failed to set timezone: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/071e0c6ec4dafb1b.
Report an issue: GitHub.