openssh icon indicating copy to clipboard operation
openssh copied to clipboard

Better error reporting when SSH failed to spawn

Open Leandros opened this issue 1 year ago • 1 comments

I'm trying to connect to an EC2 from an Amazon Linux 2 VM. However, AL2 ships with an ancient OpenSSH version from 2017:

OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017

This version doesn't yet support StrictHostKeyChecking=accept-new and quits with:

command-line line 0: unsupported option "accept-new".

However, when trying to create a new session, the error returned from SessionBuilder::launch_master is:

Err(
    Connect(
        Os {
            code: 2,
            kind: NotFound,
            message: "No such file or directory",
        },
    ),
)

Unfortunately, this gives zero indication of what went wrong. I had to step through the code and recreate the SSH invocation to find out that accept-new isn't supported.

I'd propose that the error returned also returns the stdout/stderr from the ssh invocation.

Leandros avatar Nov 26 '24 14:11 Leandros

We do have code to parse error from output.

https://github.com/openssh-rust/openssh/blob/388315384219da30c384d073db09518846b529d4/src/builder.rs#L492

However it seems that this does not catch unknown option error, we can definitely add that

NobodyXu avatar Nov 27 '24 08:11 NobodyXu