russh icon indicating copy to clipboard operation
russh copied to clipboard

Implement AgentClient::connect_uds on Windows

Open Irvingouj opened this issue 2 years ago • 9 comments

I tried to run basic examples but hit a problem with

 let mut agent = russh_keys::agent::client::AgentClient::connect_env().await.unwrap();

where connect_env returns only error on non-unix platform. Does this library supposed to work under platform otherthan linux?

Irvingouj avatar Sep 08 '23 00:09 Irvingouj

russh-keys AgentClient class only supports SSH agent connections via UNIX sockets, so it doesn't work on Windows. The rest of russh works on Windows.

Eugeny avatar Sep 08 '23 07:09 Eugeny

(if you're learning russh through examples, it's a better idea to start with remote_shell_call which is newer as opposed to client.rs which was inherited from thrussh)

Eugeny avatar Sep 08 '23 07:09 Eugeny

so it doesn't work on Windows.

FWIW, UNIX domain sockets have worked on windows for several years now, there's no reason not to support it here

wez avatar Sep 08 '23 13:09 wez

Yup but IIRC openssh agent uses a named pipe on windows instead


From: Wez Furlong @.> Sent: Friday, September 8, 2023 3:34:43 PM To: warp-tech/russh @.> Cc: Eugene @.>; State change @.> Subject: Re: [warp-tech/russh] Does this library work on Windows? (Issue #177)

so it doesn't work on Windows.

FWIW, UNIX domain sockets have worked on windows for several years nowhttps://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/, there's no reason not to support it here

— Reply to this email directly, view it on GitHubhttps://github.com/warp-tech/russh/issues/177#issuecomment-1711683254, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABHNRGKIGFMAIJ64BL2KLDXZMNHHANCNFSM6AAAAAA4PULI3M. You are receiving this because you modified the open/close state.Message ID: @.***>

Eugeny avatar Sep 08 '23 20:09 Eugeny

There are other ssh agents that run on windows that use unix domain sockets

wez avatar Sep 08 '23 21:09 wez

I was able to get this working on Windows with this small change to russh-keys:

#[cfg(windows)]
impl AgentClient<tokio::net::windows::named_pipe::NamedPipeClient> {
    pub async fn connect_windows() -> Result<Self, Error> {
        let stream = tokio::net::windows::named_pipe::ClientOptions::new()
            .open(r"\\.\pipe\openssh-ssh-agent")?;
        Ok(AgentClient {
            stream,
            buf: CryptoVec::new(),
        })
    }
}

Then agent.request_identities() returns a non-empty list.

Except it seems to not be returning my ECDSA keys:

[2023-09-22T19:01:19Z INFO  russh_keys::agent::client] Unsupported key type: Ok("ecdsa-sha2-nistp256")

eminence avatar Sep 22 '23 19:09 eminence

@eminence russh doesn't have support for ECDSA keys yet - only RSA and Ed25519

Eugeny avatar Sep 22 '23 22:09 Eugeny