Article Title: security issues that linux servers have to pay attention. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Recently, I have been paying attention to the/var/log/secure file on the Linux server and found that there are a large number of ssh failure attempts, as shown below:
Check the attempts and time of the IP address from one o'clock P.M..
As many as 9288 scans, we can see that we are trying various user names to connect. It's really nothing to do, and I don't know what software to use to get bored. Fortunately, my password is complicated enough, otherwise ..........
There are multiple secure on my server, which are intercepted by time. I will collect statistics on the secure.1 file.
Obtain the IP address and quantity:
# Grep-o '[0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \}\. [0-9] \ {1, 3 \} '/var/log/secure.1 | sort | uniq-c
So many of them make me feel cold sweat. It's really scary and I don't know what's good on my server. So I like it !!!! Of course, if you have successfully connected through ssh, the record will also be shown here.
To prevent such bored people from visiting again, you have to find a way to prevent them from scanning. I searched for information on the Internet and learned that Denyhosts can achieve this. DenyHosts is a program written in Python, it analyzes the sshd log file (/var/log/secure) and records IP addresses to/etc/hosts when repeated attacks are detected. deny file to achieve the automatic screen IP function. If you add them manually, you will not be able to get tired.
DenyHosts Official Website: http://denyhosts.sourceforge.net
The attachment has been attached to this article, which is downloaded from this website and the version is newer than version 2.6.
I. Check installation requirements
Check whether Sshd supports Tcpwrap. Denyhost can be installed only when Tcpwrap is supported.
# Ldd/usr/sbin/sshd | grep wrap
Libwrap. so.0 =>/usr/lib/libwrap. so.0 (0x00864000) // This information is supported
Check the Python version. You can directly install Python or later.
# Python-V
Python 2.4.3
All meet the requirements
[1] [2] Next page