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

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

Closed
3 tasks done
RailWar opened this issue Jan 1, 2025 · 6 comments
Closed
3 tasks done

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

RailWar opened this issue Jan 1, 2025 · 6 comments

Comments

@RailWar
Copy link

RailWar commented Jan 1, 2025

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 [email protected]
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 [email protected] [direct-streamlocal] (inactive timeout: 0)
11808 2025-01-01 07:14:17.874 debug1: server_input_channel_open: confirm [email protected]
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

@StevenBucher98
Copy link
Collaborator

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

@RailWar
Copy link
Author

RailWar commented Jan 7, 2025

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.

@StevenBucher98
Copy link
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.

@RailWar
Copy link
Author

RailWar commented Jan 9, 2025

in version 9.5p1 I get the same errors

@StevenBucher98
Copy link
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.

@RailWar
Copy link
Author

RailWar commented Jan 15, 2025

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

@RailWar RailWar closed this as completed Jan 15, 2025
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

No branches or pull requests

2 participants