I am using Ubuntu 14.04 LTS. I want to create an openssh server, which listens on many ports (at least 100 different ports). Multiple clients would connect to this server, but each client would need to have its own dedicated port. Clients would create reverse ssh tunnels to this host on-demand, and maximum number of concurrent clients would be max. 10 at a time.

When configuring 16 or more ports, Openssh server fails to start, fails with error:

fatal: Too many listen sockets. Enlarge MAX_LISTEN_SOCKS

MAX_LISTEN_SOCKS is defined in sshd.c file. Is there a way to enlarge MAX_LISTEN_SOCKS, without having to recompile and reinstall openssh server from source?

Alternative: is there a different/better way to resolve this?

closed as off-topic by Gilles, peterph, cuonglm, G-Man, Archemar Sep 11 '15 at 5:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Gilles, peterph, cuonglm, G-Man, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • you can change the value of this constant MAX_LISTEN_SOCKS only during build-time. You would need to recompile the openssh from source. – Jakuje Sep 10 '15 at 11:30
  • 1
    I'm voting to close this question since it turns out that you don't need each client to have its own dedicated port, and that's the whole point of the question here. Next time, you'll get better and quicker help if you explain your actual problem instead of assuming how it should be solved — namely you want multiple clients at the same time, and ports are actually irrelevant. – Gilles Sep 10 '15 at 22:20

You can run sshd using inetd (and optionally tcpd) on as many ports as you like with the following inetd.conf:

10000 stream tcp nowait root /usr/sbin/tcpd sshd -i
10001 stream tcp nowait root /usr/sbin/tcpd sshd -i
10002 stream tcp nowait root /usr/sbin/tcpd sshd -i

You should also read the caveats on sshd -i in the sshd manual.


Thanks for the help and for the responses, it turns out, that basically this issue is pointless. My eyes got opened by a helpful redditor ckozler: https://www.reddit.com/r/linuxadmin/comments/3kdn1r/openssh_server_fatal_too_many_listen_sockets/cuwoo02

But they'll still be connecting to YOU on port 22, the reverse SSH tunnel is a port opened on THEM to which you connect to. Your server side daemon (OpenSSH) does not need multiple listening ports to accept multiple clients. Thats the beauty of multithreaded socket servers

Basically I don't need this functionality, what I requested in my original question.

Not the answer you're looking for? Browse other questions tagged or ask your own question.