{"record":{"id":"071e0c6ec4dafb1b","repo":"lima-vm/lima","slug":"failed-to-enable-sshd-w","errorCode":null,"errorMessage":"failed to enable SSHD: %w","messagePattern":"failed to enable SSHD: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go","lineNumber":32,"sourceCode":"\t\"os/exec\"\n\t\"os/user\"\n\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/goccy/go-yaml\"\n\t\"github.com/sethvargo/go-password/password\"\n\t\"github.com/sirupsen/logrus\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/cidata/cloudinittypes\"\n\t\"github.com/lima-vm/lima/v2/pkg/osutil\"\n)\n\nfunc Run(ctx context.Context) error {\n\tconst mnt = \"/Volumes/cidata\"\n\tvar errs []error\n\tif err := enableSSHD(ctx); err != nil {\n\t\terrs = append(errs, fmt.Errorf(\"failed to enable SSHD: %w\", err))\n\t}\n\tif err := processMetaData(ctx, mnt); err != nil {\n\t\terrs = append(errs, fmt.Errorf(\"failed to process meta data: %w\", err))\n\t}\n\tif err := processUserData(ctx, mnt); err != nil {\n\t\terrs = append(errs, fmt.Errorf(\"failed to process user data: %w\", err))\n\t}\n\tif err := runBootScripts(ctx); err != nil {\n\t\terrs = append(errs, fmt.Errorf(\"failed to run boot scripts: %w\", err))\n\t}\n\treturn errors.Join(errs...)\n}\n\nfunc enableSSHD(ctx context.Context) error {\n\tcmd := exec.CommandContext(ctx, \"/bin/launchctl\", \"load\", \"-w\", \"/System/Library/LaunchDaemons/ssh.plist\")\n\tlogrus.Infof(\"Executing command: %v\", cmd.Args)\n\tif output, err := cmd.CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"failed to execute command %v: %w (output=%#q)\", cmd.Args, err, output)","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := fakecloudinit.Run(ctx); err != nil {\n    var wrapped interface{ Unwrap() error }\n    log.Errorf(\"provisioning failed: %v\", err)\n    // inspect the chain to find the underlying enableSSHD failure\n    return fmt.Errorf(\"fakecloudinit provisioning failed: %w\", err)\n}","preventionTips":["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)"],"tags":["guestagent","macos","cloud-init","sshd"],"backgroundTag":"provisioning-step-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}