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

Warm Regards

Supratik

link|improve this question

47% accept rate
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
feedback

2 Answers

up vote 2 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
link|improve this answer
3  
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
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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