Skip to content

Conversation

@norio-nomura
Copy link
Contributor

@norio-nomura norio-nomura commented Nov 13, 2025

Check the SSH server in a way that complies with the SSH protocol using x/crypto/ssh. This change fixes #4334 by falling back to usernet port forwarder on failing SSH connections over VSOCK.

  • pkg/networks/usernet: Rename entry point from /extension/wait_port to /extension/wait_ssh_server Because it changed to an SSH server-specific entry point. When a client accesses the old entry point, it fails and continues with falling back to the usernet forwarder.

  • pkg/sshutil: Add WaitSSHReady() WaitSSHReady waits until the SSH server is ready to accept connections. The dialContext function is used to create a connection to the SSH server. The addr, user, privateKeyPath parameter is used for ssh.ClientConn creation. The timeoutSeconds parameter specifies the maximum number of seconds to wait.

  • feat: Generate SSH server keys in host agent and use them in guest OS

This change changes the SSH server keys that have been generated for each boot in guest OS to be generated by hostagent for each boot.
This allows the hostagent to obtain the public key before booting, so that knownhosts can be used with an ssh connection.

The code that uses ssh.InsecureIgnoreHostKey() in x/crypto/ssh is pointed out in CodeQL as Use of insecure HostKeyCallback implementation (High), so it is an implementation to avoid this.

@norio-nomura norio-nomura force-pushed the vz-ssh-over-vsock-try-handshake branch 2 times, most recently from 6e095ed to 16b4782 Compare November 13, 2025 07:08
Check the SSH server in a way that complies with the SSH protocol using x/crypto/ssh.
This change fixes lima-vm#4334 by falling back to usernet port forwarder on failing SSH connections over VSOCK.

- pkg/networks/usernet: Rename entry point from `/extension/wait_port` to `/extension/wait_ssh_server`
  Because it changed to an SSH server-specific entry point.
  When a client accesses the old entry point, it fails and continues with falling back to the usernet forwarder.

- pkg/sshutil: Add `WaitSSHReady()`
  WaitSSHReady waits until the SSH server is ready to accept connections.
  The dialContext function is used to create a connection to the SSH server.
  The addr, user, privateKeyPath parameter is used for ssh.ClientConn creation.
  The timeoutSeconds parameter specifies the maximum number of seconds to wait.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
@norio-nomura norio-nomura force-pushed the vz-ssh-over-vsock-try-handshake branch from 16b4782 to 8ca744e Compare November 13, 2025 09:07
@norio-nomura
Copy link
Contributor Author

Expecting CI failures will be fixed by #4336 and #4341

This change changes the SSH server keys that have been generated for each boot in guest OS to be generated by hostagent for each boot.
This allows the hostagent to obtain the public key before booting, so that knownhosts can be used with an ssh connection.

The code that uses `ssh.InsecureIgnoreHostKey()` in `x/crypto/ssh` is pointed out in CodeQL as `Use of insecure HostKeyCallback implementation (High)`, so it is an implementation to avoid this.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
@norio-nomura norio-nomura force-pushed the vz-ssh-over-vsock-try-handshake branch from ea93616 to 0250449 Compare November 14, 2025 14:30
@norio-nomura
Copy link
Contributor Author

Following change added to avoid CodeQL error:

  • feat: Generate SSH server keys in host agent and use them in guest OS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template podman/fedora is no longer able to SSH

1 participant