ssh: too many connections in short succession?
I'm running a backup server using rsnapshot
, which uses rsync
, which uses ssh
to connect to the hosts from which to gather data. Usually, everything works fine. I run in to issues, however, if very little data has changed, and if there are a lot of separate directories to be backed up (more than 5).
I figured out that the issue is ssh
, which can only connect five times within roughly minute, then I have to wait again before making another attempt. This script demonstrates the issue:
#!/usr/bin/bash
for j in {1..3}
do
for i in {1..6}
do
ssh my.server.xyz 'exit' && echo "ok #${i}" || echo "failed #${i}"
done
sleep 60
done
The output looks as follows:
ok #1
ok #2
ok #3
ok #4
ok #5
ssh: connect to host my.server.xyz port 22: Connection refused
failed #6
ok #1
ok #2
ok #3
ok #4
ok #5
ssh: connect to host my.server.xyz port 22: Connection refused
failed #6
ok #1
ok #2
ok #3
ok #4
ok #5
ssh: connect to host my.server.xyz port 22: Connection refused
failed #6
Is there some sshd
option to configure this limit of 10? I'd like to be able to do up to 10 connections from the same host within a couple of seconds.
I figured out that it has not really anything to do with ssh
, but with IP tables on the server (where sshd
runs):
# iptables -S | grep 22
-A ufw-user-input -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW -m recent --update --seconds 30 --hitcount 6 --name DEFAULT --mask 255.255.255.255 --rsource -j ufw-user-limit