Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to limit the number of concurrent SSH connections to server ?

Warm Regards


share|improve this question
What SSH server? On what operating system? – sleske Jun 30 '10 at 10:37
possible duplicate of Hundreds of failed ssh logins. – Warner Jun 30 '10 at 13:18
up vote 3 down vote accepted

sleske is mostly right. You can set the maximum number of unauthenticated connections to sshd with MaxStartups (see sshd_config(5)) but that won't affect the number of authenticated connections.

You could, however, restrict the number of overall connections to sshd with a packet filter like Netfilter (iptables) using the connlimit extension.

Example (slightly modified directly from iptables(8)):

# limit the number of parallel SSH requests to 16 per class C sized network (24 bit netmask)
iptables -p tcp --syn --dport 22 -m connlimit --connlimit-above 16 --connlimit-mask 24 -j REJECT
share|improve this answer
Given the prevalence of ssh attacks on the internet you could end up DOSing yourself unless you also include a whitelist (if known). Might be a good idea to run fail2ban or similar as well. – symcbean Jun 30 '10 at 11:51

As far as I know, at least the SSH server from OpenSSH (which is the default on most Linux/Unix systems) does not have this option.

Maybe you could explain why you feel this limit to be necessary? There might be a better way to solve your problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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