abiosoft/colima · error

error retrieving Lima SSH config file for profile '%s': %w

Error message

error retrieving Lima SSH config file for profile '%s': %w

What it means

Error from sshConfig.Contents when os.ReadFile fails on the Lima-generated SSH config at <profile.LimaInstanceDir()>/ssh.config. The profile display name (minus the 'lima' prefix) is included to identify the instance.

Source

Thrown at environment/vm/lima/limautil/ssh.go:63

			line = "Host " + profileID
		}

		_, _ = fmt.Fprintln(&out, line)
	}
	return out.String()
}

const sshConfigFile = "ssh.config"

// sshConfig is the ssh configuration file for a Colima profile.
type sshConfig string

// Contents returns the content of the SSH config file.
func (s sshConfig) Contents() (string, error) {
	profile := config.ProfileFromName(string(s))
	b, err := os.ReadFile(s.File())
	if err != nil {
		return "", fmt.Errorf("error retrieving Lima SSH config file for profile '%s': %w", strings.TrimPrefix(profile.DisplayName, "lima"), err)
	}
	return string(b), nil
}

// File returns the path to the SSH config file.
func (s sshConfig) File() string {
	profile := config.ProfileFromName(string(s))
	return filepath.Join(profile.LimaInstanceDir(), sshConfigFile)
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Confirm the file exists: ls ~/.lima/colima/<profile>/ssh.config (or the profile's LimaInstanceDir)
  2. If absent, re-create the instance with 'colima start' — Lima regenerates ssh.config
  3. Fix permissions/ownership of the instance directory if present but unreadable
  4. For a broken half-created instance, 'colima delete' then 'colima start'

Example fix

# before: read fails, file missing
ls ~/.lima/colima/default/ssh.config   # No such file
# after: regenerate by starting
colima start && ls ~/.lima/colima/default/ssh.config
Defensive patterns

Strategy: validation

Validate before calling

// stat the exact file first
func sshConfigPresent(profileID string) bool {
    p := config.ProfileFromName(profileID)
    _, err := os.Stat(filepath.Join(p.LimaInstanceDir(), "ssh.config"))
    return err == nil
}

Try / catch

In Go: if _, err := os.Stat(file); errors.Is(err, fs.ErrNotExist) { trigger 'colima start' } else if err != nil { return err } before calling Contents().

Prevention

When it happens

Trigger: The ssh.config file does not exist because Lima creates it only when the instance is created/started; or it exists but is unreadable (permissions); or the instance directory was removed out-of-band.

Common situations: SSH-related commands run against a never-started or deleted profile; ~/.lima/colima/<profile> removed manually; files owned by root after sudo use; partially failed first start that never reached SSH setup.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/c71f8c9f00eab85b. Report an issue: GitHub.