Generated ssh configuration ControlPath is too coarse
- 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
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