{"record":{"id":"96a8d3bdc3fbcf9c","repo":"abiosoft/colima","slug":"error-retrieving-ssh-config-w","errorCode":null,"errorMessage":"error retrieving ssh config: %w","messagePattern":"error retrieving ssh config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"environment/vm/lima/limautil/ssh.go","lineNumber":26,"sourceCode":"\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/abiosoft/colima/config\"\n)\n\n// ShowSSH runs the show-ssh command in Lima.\n// returns the ssh output, if in layer, and an error if any\nfunc ShowSSH(profileID string) (resp struct {\n\tOutput string\n\tFile   struct {\n\t\tLima   string\n\t\tColima string\n\t}\n}, err error) {\n\tssh := sshConfig(profileID)\n\tsshConf, err := ssh.Contents()\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"error retrieving ssh config: %w\", err)\n\t}\n\n\tresp.Output = replaceSSHConfig(sshConf, profileID)\n\tresp.File.Lima = ssh.File()\n\tresp.File.Colima = config.SSHConfigFile()\n\treturn resp, nil\n}\n\nfunc replaceSSHConfig(conf string, profileID string) string {\n\tprofileID = config.ProfileFromName(profileID).ID\n\n\tvar out bytes.Buffer\n\tscanner := bufio.NewScanner(strings.NewReader(conf))\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\n\t\tif strings.HasPrefix(line, \"Host \") {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/environment/vm/lima/limautil/ssh.go#L8-L44","documentation":"Wrapper error from ShowSSH when reading the SSH config contents (ssh.Contents()) fails before colima can rewrite host/port into the Lima-generated config. It is the outer wrap of the file-read error surfaced by sshConfig.Contents.","triggerScenarios":"Calling ShowSSH (colima ssh-config / ssh path resolution) for a profile whose Lima ssh.config file cannot be read — usually because the instance was never created/started, or the file was deleted.","commonSituations":"Running 'colima ssh-config' after 'colima delete' or before the first successful start; CI scripts assuming an instance exists; profile name mismatch via -p.","solutions":["Start the instance first: 'colima start', then re-run the ssh-config command","Verify the underlying file exists (see error 215 for the path)","Check -p / COLIMA_DEFAULT_PROFILE targets an existing profile with 'colima list'"],"exampleFix":"# before\ncolima ssh-config -p gone   # error retrieving ssh config\n# after\ncolima start -p gone && colima ssh-config -p gone","handlingStrategy":"validation","validationCode":"// only ask for ssh config when the instance is up\nif i, err := limautil.Instance(); err != nil || !i.Running() {\n    return fmt.Errorf(\"start the VM before requesting ssh config\")\n}\nresp, err := limautil.ShowSSH(profileID)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Gate ssh-config/ssh commands on 'colima status' showing Running","Remember the underlying file is Lima-generated: no start, no file"],"tags":["ssh","config","profile","lifecycle"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}