lima-vm / lima-vm/lima

Generated ssh configuration ControlPath is too coarse

Open
#5,062 3 comments 0 reactions 0 assignees View on GitHub
area/cli enhancement
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

### Description

The ssh config files in `~/.lima/MACHINE/ssh.config` include:

```text
Host lima-MACHINE
ControlMaster auto
ControlPath "/Users/USERNAME/.lima/MACHINE/ssh.sock"
ControlPersist yes
# ...
```

If you want to be able to connect to the machine as more than one user, this configuration breaks it in a confusing way.

```text
user@host$ ssh firstuser@lima-MACHINE
firstuser@lima-MACHINE$ whoami
firstuser
firstuser@lima-MACHINE$ exit
user@host$ ssh seconduser@lima-MACHINE
firstuser@lima-MACHINE$ whoami
firstuser
```

As a workaround you can put a line like this in `~/.ssh/config` before the lima include:

```text
Host lima-MACHINE
ControlPath ~/.lima/MACHINE/ssh.sock.%r

Include ~/.lima/*/ssh.config
```

But it would be nice if lima would configure this itself.

(You might prefer to use `~/.lima/MACHINE/ssh.sock.%C`, which includes a hash of the username/hostname/port. The hostname doesn't help here, but the port might be useful if the user ever wanted to run a second ssh server on a different port.)

Contributor guide

Open the contributing guide

Research direction

Start by tracing the code that generates ~/.lima/MACHINE/ssh.config and inspect how its ControlPath is selected. Reproduce connections as two users, then verify that the generated socket path separates users while preserving normal SSH connections; the issue leaves the choice between %r and %C open.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.