PowerShell / PowerShell/Win32-OpenSSH

Fail to RemoteForward a unix domain socket

Open
#1,564 21 comments 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Enhancement
Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

"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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three RemoteForward configurations on OpenSSH for Windows 7.7.2.1 and compare their failures. Start at the streamlocal forwarding path, including client_request_forwarded_streamlocal, CreateFileW, the forwarding parser, and w32_getsockopt. Done means forwarding the Windows gpg-agent socket to Linux works without the reported path, parsing, or socket errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.