Skip to content

Port forwarding to unix socket or named pipe to Windows #2321

Closed

Description

@RailWar

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

I try a tcp port 22222 forward to unix socket or named pipe on same windows (localhost). I use application witten on c++ as unix socket server and pipes server. sshd_config is original, unmodified.

Expected behavior

unix socket
--------------
us_serer.exe (my test program)
ssh -N -vvv -L localhost:22222:/Users/RailWar/AppData/Local/Temp/my_unix.sock localhost
putty as raw client to port 22222

pipe
------------
pipe_server.exe (my test program)
ssh -N -vvv -L localhost:22222://./pipe/my_pipe localhost
putty as raw client to port 22222

Actual behavior

unix sockets server sees the connection, but does not receive the message and immediately closes. 
pipes server does not see any clients.
I get errors in the file c:\ProgramData\ssh\logs\sshd-session.log

Error details

c:\ProgramData\ssh\logs\sshd-session.log (last messages with errors)

unix socket
-----------
13520 2025-01-01 07:11:11.234 debug1: server_request_direct_streamlocal: originator 127.0.0.1 port 55629, target /Users/RailWar/AppData/Local/Temp/my_unix.sock
13520 2025-01-01 07:11:11.234 debug1: connect_next: start for host /Users/RailWar/AppData/Local/Temp/my_unix.sock ([unix]:/Users/RailWar/AppData/Local/Temp/my_unix.sock)
13520 2025-01-01 07:11:11.234 debug2: fd 11 setting O_NONBLOCK
13520 2025-01-01 07:11:11.234 debug3: unable to connect to pipe /Users/RailWar/AppData/Local/Temp/my_unix.sock, error: 1920
13520 2025-01-01 07:11:11.234 debug1: connect_next: host /Users/RailWar/AppData/Local/Temp/my_unix.sock ([unix]:/Users/RailWar/AppData/Local/Temp/my_unix.sock): Unknown error
13520 2025-01-01 07:11:11.234 error: connect to /Users/RailWar/AppData/Local/Temp/my_unix.sock port -2 failed: Unknown error
13520 2025-01-01 07:11:11.234 debug1: server_input_channel_open: failure direct-streamlocal@openssh.com
13520 2025-01-01 07:11:11.234 debug3: send packet: type 92

named pipe
----------
11808 2025-01-01 07:14:17.874 debug1: server_request_direct_streamlocal: originator 127.0.0.1 port 55699, target //./pipe/my_pipe
11808 2025-01-01 07:14:17.874 debug1: connect_next: start for host //./pipe/my_pipe ([unix]://./pipe/my_pipe)
11808 2025-01-01 07:14:17.874 debug2: fd 11 setting O_NONBLOCK
11808 2025-01-01 07:14:17.874 debug1: connect_next: connect host //./pipe/my_pipe ([unix]://./pipe/my_pipe) in progress, fd=11
11808 2025-01-01 07:14:17.874 debug3: fd 11 is O_NONBLOCK
11808 2025-01-01 07:14:17.874 debug3: fd 11 is O_NONBLOCK
11808 2025-01-01 07:14:17.874 debug1: channel 0: new direct-streamlocal@openssh.com [direct-streamlocal] (inactive timeout: 0)
11808 2025-01-01 07:14:17.874 debug1: server_input_channel_open: confirm direct-streamlocal@openssh.com
11808 2025-01-01 07:14:17.874 debug3: channel 0: waiting for connection
11808 2025-01-01 07:14:17.874 debug3: w32_getsockopt ERROR: not sock :2
11808 2025-01-01 07:14:17.874 error: getsockopt SO_ERROR failed
11808 2025-01-01 07:14:17.874 debug1: channel 0: connection failed: Not a socket
11808 2025-01-01 07:14:17.874 error: connect_to //./pipe/my_pipe port -2: failed.
11808 2025-01-01 07:14:17.874 debug3: send packet: type 92
11808 2025-01-01 07:14:17.874 debug2: channel 0: zombie
11808 2025-01-01 07:14:17.874 debug2: channel 0: garbage collecting
11808 2025-01-01 07:14:17.874 debug1: channel 0: free: direct-streamlocal, nchannels 1

Environment data

PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version

OpenSSH_for_Windows_9.8p1 Win32-OpenSSH-GitHub, LibreSSL 3.9.2

Visuals

No response

Activity

  1. StevenBucher98 commented on Jan 6, 2025

    @StevenBucher98
    Collaborator

    Evgeny (@RailWar) was this working with OpenSSH 9.5? We are curious if this is a regression

  2. RailWar commented on Jan 7, 2025

    @RailWar
    Author

    I don't know. But I thing that doesn't work. I found a fork at https://github.com/crunchloop/openssh-portable/tree/add-af-unix-support. I made one adding and now I got a working unix domain socket on Windows. I will check that named pipes work in this fork. Saddly that this fork waits a merging a long time.

  3. StevenBucher98 commented on Jan 7, 2025

    @StevenBucher98
    Collaborator

    If you could test your scenario on 9.5 that would help us identify if this is a regression or not. I suspect it isnt but good to rule out regardless.

  4. RailWar commented on Jan 9, 2025

    @RailWar
    Author

    in version 9.5p1 I get the same errors

  5. StevenBucher98 commented on Jan 13, 2025

    @StevenBucher98
    Collaborator

    Digging deeper and found this PR on the topic, PowerShell/openssh-portable#674, looks like you found it to 😄. We plan to revisit this PR but do not have an ETA yet as far as merging.

  6. RailWar commented on Jan 15, 2025

    @RailWar
    Author

    It is good news. There are minimal changes. I hope that you will be able to do this merger sooner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions