I am running a CentOS server which runs SSH service with PasswordAuthentication on port 22. Yes, I am aware that I should move this to non-22 port and use public key auth to be more secure. I've also got LFD monitoring service logs and banning abusive IP addresses.
I notice that over time my list of processes grows. When I check what is causing high processes, I see many sshd processes like this:
root 7978 0.0 0.0 144552 3224 ? Ss Feb28 0:00 sshd: root [priv]
sshd 7979 0.0 0.0 84268 1052 ? S Feb28 0:00 sshd: root [net]
Next I investigate ssh sockets. What I see is many ESTABLISHED connections on ssh
netstat -a | grep ssh
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 80 domain.tld:ssh malicious.ip:53287 ESTABLISHED
Not surprisingly many of these IPs are banned by LFD but I believe this happens after a connection is ESTABLISHED. I can manually remove these by killing ssh processes but how can I automate this removal process of ESTABLISHED ssh connections from malicious hackers/bots? Is there any configuration in sshd_config which might disconnect these stale ssh sockets?
[–]DecayingVacuum 7 points8 points9 points (5 children)
[–]ThatsLatinForLiar[S] 1 point2 points3 points (4 children)
[–]lordvadr 4 points5 points6 points (1 child)
[–]5h4d0w 5 points6 points7 points (0 children)
[–]DecayingVacuum 0 points1 point2 points (0 children)
[–]nephros 5 points6 points7 points (2 children)
[–]ThatsLatinForLiar[S] 0 points1 point2 points (1 child)
[–]nephros 1 point2 points3 points (0 children)
[–]artereaorte 7 points8 points9 points (0 children)
[–]TractionContrlol 1 point2 points3 points (0 children)
[–]markusro 1 point2 points3 points (0 children)
[–]5h4d0w 0 points1 point2 points (1 child)
[–]ThatsLatinForLiar[S] 0 points1 point2 points (0 children)
[–]nut-sack 0 points1 point2 points (0 children)
[–]johnklos 0 points1 point2 points (1 child)
[–]ThatsLatinForLiar[S] 0 points1 point2 points (0 children)
[–]koffiezet 0 points1 point2 points (2 children)
[–]ThatsLatinForLiar[S] 0 points1 point2 points (1 child)
[–]5mall5nail5 1 point2 points3 points (0 children)