Skip to content

Commit 06b2ff0

Browse files
committed
Stop using hard-coded port 60022 for "default" instance
The "default" instance no longer uses 60022 as the TCP port. Discussed in issue 3712. This change affects the existing "default" instance too, however, users do not need to care about the port number if they use `~/.lima/default/ssh.config`: ``` ssh -F ~/.lima/default/ssh.config lima-default ``` Signed-off-by: Akihiro Suda <[email protected]>
1 parent c1b8496 commit 06b2ff0

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

pkg/hostagent/hostagent.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func New(instName string, stdout io.Writer, signalCh chan os.Signal, opts ...Opt
111111
}
112112

113113
// inst.Config is loaded with FillDefault() already, so no need to care about nil pointers.
114-
sshLocalPort, err := determineSSHLocalPort(*inst.Config.SSH.LocalPort, instName)
114+
sshLocalPort, err := determineSSHLocalPort(*inst.Config.SSH.LocalPort)
115115
if err != nil {
116116
return nil, err
117117
}
@@ -237,17 +237,13 @@ func writeSSHConfigFile(sshPath, instName, instDir, instSSHAddress string, sshLo
237237
return os.WriteFile(fileName, b.Bytes(), 0o600)
238238
}
239239

240-
func determineSSHLocalPort(confLocalPort int, instName string) (int, error) {
240+
func determineSSHLocalPort(confLocalPort int) (int, error) {
241241
if confLocalPort > 0 {
242242
return confLocalPort, nil
243243
}
244244
if confLocalPort < 0 {
245245
return 0, fmt.Errorf("invalid ssh local port %d", confLocalPort)
246246
}
247-
if instName == "default" {
248-
// use hard-coded value for "default" instance, for backward compatibility
249-
return 60022, nil
250-
}
251247
sshLocalPort, err := freeport.TCP()
252248
if err != nil {
253249
return 0, fmt.Errorf("failed to find a free port, try setting `ssh.localPort` manually: %w", err)

templates/default.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ additionalDisks:
122122
ssh:
123123
# A localhost port of the host. Forwarded to port 22 of the guest.
124124
# 🟢 Builtin default: 0 (automatically assigned to a free port)
125-
# NOTE: when the instance name is "default", the builtin default value is set to
126-
# 60022 for backward compatibility.
127125
localPort: null
128126
# Load ~/.ssh/*.pub in addition to $LIMA_HOME/_config/user.pub .
129127
# This option is useful when you want to use other SSH-based

website/content/en/docs/config/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ The current default spec:
1111
- Memory: 4 GiB
1212
- Disk: 100 GiB
1313
- Mounts: `~` (read-only), `/tmp/lima` (writable)
14-
- SSH: 127.0.0.1:60022
14+
- SSH: 127.0.0.1:<Random port>
1515

1616
For environment variables, see [Environment Variables](./environment-variables/).

website/content/en/docs/faq/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ weight: 6
5050
Password is disabled and locked by default.
5151
You have to use `limactl shell bash` (or `lima bash`) to open a shell.
5252

53-
Alternatively, you may also directly ssh into the guest: `ssh -p 60022 -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes 127.0.0.1`.
53+
Alternatively, you may also directly ssh into the guest: `ssh -p <PORT> -i ~/.lima/_config/user -o NoHostAuthenticationForLocalhost=yes 127.0.0.1`.
54+
The port number can be inspected by running `limactl list`.
5455

5556
#### "Does Lima work on ARM Mac?"
5657
Yes

0 commit comments

Comments
 (0)