{"record":{"id":"6defad689d738cef","repo":"lima-vm/lima","slug":"no-ssh-key-was-found-run-ssh-keygen","errorCode":null,"errorMessage":"no SSH key was found, run `ssh-keygen`","messagePattern":"no SSH key was found, run `ssh-keygen`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cidata/cidata.go","lineNumber":192,"sourceCode":"\t\t}\n\t\targs.SlirpGateway = usernet.GatewayIP(subnet)\n\t\tif *instConfig.VMType == limatype.VZ {\n\t\t\targs.SlirpDNS = usernet.GatewayIP(subnet)\n\t\t} else {\n\t\t\targs.SlirpDNS = usernet.DNSIP(subnet)\n\t\t}\n\t\targs.SlirpIPAddress = networks.SlirpIPAddress\n\t}\n\n\t// change instance id on every boot so network config will be processed again\n\targs.IID = fmt.Sprintf(\"iid-%d\", time.Now().Unix())\n\n\tpubKeys, err := sshutil.DefaultPubKeys(ctx, *instConfig.SSH.LoadDotSSHPubKeys)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(pubKeys) == 0 {\n\t\treturn nil, errors.New(\"no SSH key was found, run `ssh-keygen`\")\n\t}\n\tfor _, f := range pubKeys {\n\t\targs.SSHPubKeys = append(args.SSHPubKeys, f.Content)\n\t}\n\n\tvar fstype string\n\tswitch *instConfig.MountType {\n\tcase limatype.REVSSHFS:\n\t\tfstype = \"sshfs\"\n\tcase limatype.NINEP:\n\t\tfstype = \"9p\"\n\t\tif *instConfig.OS == limatype.FREEBSD {\n\t\t\tfstype = \"p9fs\"\n\t\t}\n\tcase limatype.VIRTIOFS:\n\t\tfstype = \"virtiofs\"\n\t}\n\thostHome, err := localpathutil.Expand(\"~\")","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/cidata/cidata.go#L174-L210","documentation":"templateArgs collects SSH public keys to inject into the guest's cloud-config (authorized_keys). If sshutil.DefaultPubKeys finds zero usable public keys (and loading ~/.ssh pubkeys is enabled), generating the ISO/cloud-config cannot proceed, so this instructive error is thrown telling the user to create a key.","triggerScenarios":"Generating the cidata image (limactl create/start, GenerateCloudConfig, GenerateISO9660, GenerateWindowsISO) when no public keys exist: no ~/.ssh/*.pub, and ssh.LoadDotSSHPubKeys is true (default) with an empty ~/.ssh, or key generation via ssh-keygen is unavailable/failed.","commonSituations":"Fresh machine or CI container with no ~/.ssh directory; HOME misconfigured so ~/.ssh isn't found; only encrypted/private keys present without .pub files; setting ssh.loadDotSSHPubKeys=false in lima.yaml without providing other auth.","solutions":["Run `ssh-keygen -t ed25519` to create a default key pair, then retry","Ensure your keys are standard public keys in ~/.ssh (*.pub) readable by the current user","Verify $HOME points to the right directory so ~/.ssh is discoverable","If you intend other auth, set ssh.loadDotSSHPubKeys: false in lima.yaml and supply keys via another mechanism — otherwise keep it true with at least one key"],"exampleFix":"// before: lima.yaml\nssh:\n  loadDotSSHPubKeys: true\n# shell fix\nssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519","handlingStrategy":"validation","validationCode":"// Go: ensure at least one public key exists before create/start\npubKeys, err := sshutil.DefaultPubKeys(ctx, true)\nif err != nil || len(pubKeys) == 0 {\n    return errors.New(\"run `ssh-keygen -t ed25519` before `limactl create`\")\n}\n","typeGuard":null,"tryCatchPattern":"if err := limainstance.Create(ctx, inst); err != nil {\n    if strings.Contains(err.Error(), \"no SSH key was found\") {\n        exec.Command(\"ssh-keygen\", \"-t\", \"ed25519\", \"-N\", \"\", \"-f\",\n            filepath.Join(home, \".ssh\", \"id_ed25519\")).Run()\n        return limainstance.Create(ctx, inst)\n    }\n    return err\n}\n","preventionTips":["Run ssh-keygen once on new machines/CI images before limactl create/start","Verify $HOME resolves to a directory containing .ssh/*.pub","Only set ssh.loadDotSSHPubKeys: false if you provide guest keys another way","In CI, generate a throwaway key (ssh-keygen -N '' -f key) as a setup step"],"tags":["ssh","cidata","cloud-init","configuration"],"backgroundTag":"missing-ssh-key","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}