Skip to content

fix: Properly support multi-word executables set via SSH environment variable #3783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

muchzill4
Copy link

Fixes an issue with multi-word, custom ssh command specified via environment variable SSH.
As an example, when export SSH="kitty ssh" is used, some pre-flight checks use only kitty which causes warnings to be logged.
The fix introduces SSHExe type to encapsulate whole multi-word executable.

I've also noticed that detectOpenSSHInfo would never work properly for kitty ssh, nor aliases or scripts, so decided to add a comment while I was in the area.

Before

~/D/v/lima properly-support-multi-word-SSH-env• 
❱ env | rg SSH=
SSH=kitten ssh
~/D/v/lima properly-support-multi-word-SSH-env• 
❱ limactl shell podman
WARN[0000] failed to run [/opt/homebrew/bin/kitten -o GSSAPIAuthentication=no -V]: stderr="Error: Unknown option: -o. Did you mean:\n\t-h\n" 
[user@lima-podman lima]$ 

After

~/D/v/lima properly-support-multi-word-SSH-env• 
❱ ./_output/bin/limactl shell podman
[user@lima-podman lima]$ 

}

func NewSSHExe() (SSHExe, error) {
var sshExe SSHExe
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Author

@muchzill4 muchzill4 Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you mean the introduction of NewSSHExe()? If so, then the idea behind it was to introduce a single, validated entry point for SSHExe instances.

The main motivation is ensuring pre-flight checks, such as exec.LookPath("ssh") has happened. This gives us (more) confidence that the instance you're working with is functional.

Without that, different parts of the code would create SSHExe using a literal, which would bypass custom environment variable or the pre-flight check.

As a bonus, this also cleaned up redundant validation. Previously detectOpenSSHInfo was redundantly calling exec.LookPath(), though the same check might've already happened in the previous version of this function (when it was called SSHArguments).

@muchzill4
Copy link
Author

Is test / Integration tests expected to be flaky? I wonder if my change introduced the flakiness, as same test has passed @ 5c3d467.

@AkihiroSuda AkihiroSuda requested a review from afbjorklund August 4, 2025 06:17
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.

2 participants