2

I've been running this script for a few days:

while [ true ]; do ssh USER@SERVER echo -n . || date +"%s"; done

Obviously, my terminal is filled with dots, but sometimes (quite rarely) I get this

.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................
..............ssh: connect to host SERVER port 22: Connection refused
1323454879
ssh: connect to host SERVER port 22: Connection refused
1323454879
ssh: connect to host SERVER port 22: Connection refused
[snip]
1323454879
ssh: connect to host SERVER port 22: Connection refused
1323454879
ssh: connect to host SERVER port 22: Connection refused
.......................................................................
.......................................................................
.......................................................................
.......................................................................
.......................................................................

I tried this with different server providers, source servers, target servers, time of day, geographic locations. Sooner or later that error comes up for a brief second or two.

Is this to be expected or do I have an issue?

pitr
  • 129

2 Answers2

1

This is likely not aberrant behavior but something to be expected.

You may want to check:

  • firewall rules

  • anti-brute force tools

  • ssh configuration

Firewall rules can rate limit SSH connections. I use this in many of my iptables-based firewalls to stifle brute force SSH attacks. The rules limit then nubmer of new connections to a specified port.

There are tools like fail2ban, denyhosts, and others that may block access after a number of attempts.

Lastly, SSH's configuration (sshd_config) may have a maxium number of servers specified. If you are rapidly hitting SSH, you may hit this limit.

jeffatrackaid
  • 4,182
  • 21
  • 22
0

This error means that the destination server is reachable, but the port 22 is closed (SSH daemon is not running or running on non-default port).

Another possibility is that you have a firewall between you and the destination server that translates the port 22 to something else not opened on the destination server.

You did not say whether you are getting this error always on the same server or not.

Khaled
  • 37,789