Skip to content
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

connecting to ssh-agent failed under windows openssh installation. #125

Closed
jianglibo opened this issue Aug 8, 2019 · 4 comments · Fixed by #214
Closed

connecting to ssh-agent failed under windows openssh installation. #125

jianglibo opened this issue Aug 8, 2019 · 4 comments · Fixed by #214

Comments

@jianglibo
Copy link

jianglibo commented Aug 8, 2019

make sure ssh-agent is running:

Status   Name               DisplayName
------   ----               -----------
Running  ssh-agent          OpenSSH Authentication Agent

make sure ssh-add is working.

I ran the code bellow it always return error: 'Error { code: -42, msg: "failed connecting agent" }', maybe is an issue of libssh2.

    #[test]
    fn t_main_agent_inspect() {
        // Almost all APIs require a `Session` to be available
        let sess = Session::new().unwrap();
        let mut agent = sess.agent().unwrap();

        // Connect the agent and request a list of identities
        agent.connect().unwrap();
        agent.list_identities().unwrap();

        for identity in agent.identities() {
            let identity = identity.unwrap(); // assume no I/O errors
            println!("{}", identity.comment());
            let pubkey = identity.blob();
            println!("{:?}", pubkey);
        }
    }
@wez
Copy link
Collaborator

wez commented Aug 8, 2019

Looking at the code in libssh2, it looks like it prefers to use the putty pageant, and then falls back to using the contents of $SSH_AUTH_SOCK if PF_UNIX is defined. I'm not sure that PF_UNIX is defined consistently when building libssh2 (probably not for the gnu toolchain, and it depends on your local compiler installation for MSVC), so the unix domain code is probably not even enabled on windows. In addition, SSH_AUTH_SOCK doesn't appear to be set for me on Windows either... so I suspect that there is some amount of work needed to teach libssh2 how to talk to the agent on windows, and then to make sure that we enable that code here in the rust bindings that bundle and build the library.

I would suggest opening an issue at https://github.com/libssh2/libssh2/issues/new/choose to see what the libssh2 folks think about making this work in libssh2, and then we can follow up from there.

@jianglibo
Copy link
Author

Yes. Maybe only the ssh.exe come with ssh-agent.exe can understand this specialized ssh-agent service.

@wez
Copy link
Collaborator

wez commented Sep 16, 2019

(closing since this is something that needs to be addressed in the underlying libssh2 library)

@wez wez closed this as completed Sep 16, 2019
@yodaldevoid
Copy link
Collaborator

yodaldevoid commented Dec 3, 2020

I am attempting to add support for ssh-agent.exe in libssh2/libssh2#517, but the maintainers of libssh2 would like someone with Windows experience to take a look at the code before merging it. I don't know if any of the maintainers of ssh2-rs would be able to comment on that PR, but it would be appreciated.

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 a pull request may close this issue.

3 participants