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

ssh.exe local port forwarding limited to 32 connections #191

Closed
scottmckenzie opened this issue Apr 19, 2016 · 7 comments
Closed

ssh.exe local port forwarding limited to 32 connections #191

scottmckenzie opened this issue Apr 19, 2016 · 7 comments

Comments

@scottmckenzie
Copy link

I have an ssh server which I am using to tunnel connections to remote servers. In my .ssh\config file I have lots (>32) of LocalForward directives for this server like so:
LocalForward 127.0.0.1:13389 remoteserver.localnet:3389

When my config file contains more than 32 LocalForward directives I can no longer connect to my jumphost. I receive the error select: Overlapped I/O operation is in progress.. If I limit the LocalForward directives to 32 then I can successfully connect.

This seems to have been introduced in release 3_19_2016 which I believe included new I/O code. Release 2_25_2016 allows me to connect to my jumphost with more than 32 local port forwardings.

@manojampalam
Copy link
Contributor

This is due to a internal enforced limit. This can be upped a bit more but making it boundless requires a multi threaded solution that I would like to avoid.
A work around would be to make a copy of ssh.exe and ssh_config in a separate directory, split LocalForward directives between ssh_configs and run separate instances of ssh.exe

@jhudsoncedaron
Copy link

@manojampalam Ah yes you ran into an inherent design flaw in Windows. It's not the first you will hit.

Knowing the flaws involved when I attempted to plan a port, I'm surprised that MS didn't just decide to fix the Windows problems first. Problem #1: Can't wait for thousands of handles per thread. Problem #2: Can't create anything like a PTY so a console app that wants to change TTY settings does not signal the server end and so it doesn't pass down the network pipe. Problem #3: Trying UTF-8 on the console explodes, but essentially all ssh links are either UTF-8 Text or binary and ssh can't tell the difference.

@nkrepo
Copy link

nkrepo commented Nov 1, 2017

I am using "OpenSSH for Windows" version 0.0.22.0 at
Microsoft Windows 10 Pro 64-bit 10.0.16299 (Fall Creators Update)

@manojampalam
The number of local ports that can be forwarded is limited to 16 instead of 32.
When I try to forward more than 16 local ports I get the following error:
"select: Not enough space"

@manojampalam
Copy link
Contributor

@nkrepo there were no changes in the limit. Can you share your repro steps?

@nkrepo
Copy link

nkrepo commented Nov 2, 2017

@manojampalam
I used a simple PowerShell script that called ssh.exe and specified more than 16 local port forwards like the following.

ssh -L 3301:192.168.0.1:1123 `  
       ... `
      -L 3317:192.168.0.17:1123 `
      [email protected]

@manojampalam
Copy link
Contributor

Try with -4 parameter. My guess is you are ending up listening on IPv6 address too for each forwarded port. That will double the number of sockets you are listening on.

@nkrepo
Copy link

nkrepo commented Nov 3, 2017

@manojampalam you are correct it was binding to both IPv4 and IPv6 address now it works up to 32 local port forwards. I had disabled IPv6 for the physical network adapter but not system-wide, therefore the Loopback Pseudo-Interface still has an IPv6 address.

Get-NetIPAddress -ifIndex 1

IPAddress         : ::1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv6
...
PolicyStore       : ActiveStore

IPAddress         : 127.0.0.1
InterfaceIndex    : 1
InterfaceAlias    : Loopback Pseudo-Interface 1
AddressFamily     : IPv4
...
PolicyStore       : ActiveStore

@manojampalam manojampalam added Issue-Enhancement Feature request and removed 0 - Backlog labels Mar 20, 2018
manojampalam pushed a commit to PowerShell/openssh-portable that referenced this issue Mar 20, 2018
PowerShell/Win32-OpenSSH#1096
PowerShell/Win32-OpenSSH#191

- Updated wait_for_multiple_objects_enhanced() to handle a no-event request while alterable.
- Simplified wait_for_any_event() to by taking advantage of no-event alterable request in wait_for_multiple_objects_enhanced().
- Updated wait_for_any_event() to use MAX_CHILDREN limit instead of MAXIMUM_WAIT_OBJECTS limit.
- Removed unnecessary ZeroMemory() call.
- Created distinct definition MAXIMUM_WAIT_OBJECTS_ENHANCED
 and modified functions to use it.
- Upped w32_select() event limit.
- Modified wait_for_multiple_objects_enhanced() to allow for 0 millisecond wait.
@manojampalam manojampalam added this to the vNext milestone Mar 20, 2018
@manojampalam manojampalam modified the milestones: vNext, 7.6.1.0p1-Beta Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants