problems with ssh

Can’t connect to router with ssh. The bug appears to be quite random, i have routers versioning from 2.8 to 2.9.6. To some i can log in with ssh, to others not. Fresh install doesn’t have this problem, so it appears to manifest itself in time.
ssh client says:

ssh_exchange_identification: Connection closed by remote host

Has anyone experienced similar problems?

Maybe firewall?

What firewall? Hopefully mikrotik doesn’t have firewalls manifesting themselves in random times. Seriously, i have some firewall rules, but none governing input chain.
I was thinking that maybe tihs bug manifests itself because it gets awfully lot of ssh login attempts, i have logged on and seen like 13k failed attempts due to viruses or bots or whatever evil things they are.

I understood this is not random behaviour, I thought the problem just starts after some time and then it never works again. I suspected either some manual or automatic changes in firewall happened. But, if this is random and you have lot of failed connections to port 22, that can be the problem. Try to limit access to port 22 in input chain just to your IP range. ssh probably thinks this is DoS attack or brute force hack attack and then it stops responding for some time.

Seems like your connection tracking table is full. Limit connection number, decrease connection timeout or upgrade to the latest 2.9 version which has some improvements regarding this.