abiosoft/colima · error

error retrieving ssh config: %w

Error message

error retrieving ssh config: %w

What it means

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.

Source

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

	"path/filepath"
	"strings"

	"github.com/abiosoft/colima/config"
)

// ShowSSH runs the show-ssh command in Lima.
// returns the ssh output, if in layer, and an error if any
func ShowSSH(profileID string) (resp struct {
	Output string
	File   struct {
		Lima   string
		Colima string
	}
}, err error) {
	ssh := sshConfig(profileID)
	sshConf, err := ssh.Contents()
	if err != nil {
		return resp, fmt.Errorf("error retrieving ssh config: %w", err)
	}

	resp.Output = replaceSSHConfig(sshConf, profileID)
	resp.File.Lima = ssh.File()
	resp.File.Colima = config.SSHConfigFile()
	return resp, nil
}

func replaceSSHConfig(conf string, profileID string) string {
	profileID = config.ProfileFromName(profileID).ID

	var out bytes.Buffer
	scanner := bufio.NewScanner(strings.NewReader(conf))

	for scanner.Scan() {
		line := scanner.Text()

		if strings.HasPrefix(line, "Host ") {

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Start the instance first: 'colima start', then re-run the ssh-config command
  2. Verify the underlying file exists (see error 215 for the path)
  3. Check -p / COLIMA_DEFAULT_PROFILE targets an existing profile with 'colima list'

Example fix

# before
colima ssh-config -p gone   # error retrieving ssh config
# after
colima start -p gone && colima ssh-config -p gone
Defensive patterns

Strategy: validation

Validate before calling

// only ask for ssh config when the instance is up
if i, err := limautil.Instance(); err != nil || !i.Running() {
    return fmt.Errorf("start the VM before requesting ssh config")
}
resp, err := limautil.ShowSSH(profileID)

Prevention

When it happens

Trigger: 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.

Common situations: Running 'colima ssh-config' after 'colima delete' or before the first successful start; CI scripts assuming an instance exists; profile name mismatch via -p.

Related errors


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