Skip to content

Fail to RemoteForward a unix domain socket #1564

Open
@BusyJay

Description

@BusyJay

"OpenSSH for Windows" version

7.7.2.1

Server OperatingSystem

Linux

Client OperatingSystem

Windows 10 Pro

What is failing

I'm trying to forward my local gpg-agent to remote server. Same configuration works fine when both ends are Linux. When trying to forward from Windows to Linux, it doesn't work anymore.
There are three kind of errors.

  1. When using configuration RemoteForward /run/user/1000/gnupg/S.gpg-agent ~/AppData/Roaming/gnupg/S.gpg-agent.extra, client reports forward success, but it won't work when actually testing it.

    debug1: remote forward success for: listen /run/user/1000/gnupg/S.gpg-agent:-2, connect ~/AppData/Roaming/gnupg/S.gpg-agent.extra:-2
    debug1: client_input_channel_open: ctype forwarded-streamlocal@openssh.com rchan 3 win 2097152 max 32768
    debug1: client_request_forwarded_streamlocal: /run/user/1000/gnupg/S.gpg-agent
    debug2: fd 8 setting O_NONBLOCK
    debug3: unable to connect to pipe ~/AppData/Roaming/gnupg/S.gpg-agent.extra, error: 3
    debug1: connect_next: host ~/AppData/Roaming/gnupg/S.gpg-agent.extra ([unix]:~/AppData/Roaming/gnupg/S.gpg-agent.extra): No such file or directory
    connect to ~/AppData/Roaming/gnupg/S.gpg-agent.extra port -2 failed: No such file or directory
    debug1: failure forwarded-streamlocal@openssh.com
    

    I suspect it's because CreateFileW can't expand charater ~ to home directory.

  2. When configuring using RemoteForward /run/user/1000/gnupg/S.gpg-agent C:/Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra, client reports parse error: Bad forwarding specification.

    I guess configuration parser just can't stand :.

  3. When configuring using RemoteForward /run/user/1000/gnupg/S.gpg-agent /Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra, and execute in disk C, client finally build up the channel successfully, but fails when handling connection.

    debug1: remote forward success for: listen /run/user/1000/gnupg/S.gpg-agent:-2, connect /Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra:-2
    debug1: client_input_channel_open: ctype forwarded-streamlocal@openssh.com rchan 3 win 2097152 max 32768
    debug1: client_request_forwarded_streamlocal: /run/user/1000/gnupg/S.gpg-agent
    debug2: fd 8 setting O_NONBLOCK
    debug1: connect_next: host /Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra ([unix]:/Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra) in progress, fd=8
    debug3: fd 8 is O_NONBLOCK
    debug3: fd 8 is O_NONBLOCK
    debug1: channel 1: new [forwarded-streamlocal]
    debug1: confirm forwarded-streamlocal@openssh.com
    debug3: channel 1: waiting for connection
    debug3: w32_getsockopt ERROR: not sock :2
    getsockopt SO_ERROR failed
    debug1: channel 1: connection failed: Not a socket
    connect_to /Users/me/AppData/Roaming/gnupg/S.gpg-agent.extra port -2: failed.
    

    That's because w32_getsockopt rejects work on a unix domain socket, it seems like a bug.

I guess there is no way to get around this now. Any suggestions?

Expected output
gpg-agent is forwarded successfully.

Actual output
It fails.

Editted:
For those who wants to forward gpg agent like me, I wrote a tool that built a bridge between GnuPG and openssh.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions