Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Warm Regards

Supratik

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

2 Answers 2

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
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

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

 
discard

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.