Linux to prevent ssh brute force

  

Today in Shanda cloud saw a good post to prevent ssh brute force, turn around and share with you, mainly rely on denyhost software. The steady thing is to download the installation package installation, you can actually use yum or apt to install directly, find the corresponding source. The following is the original text:

DenyHosts official website is: http://denyhosts.sourceforge.net 1. Installation # tar -zxvf DenyHosts-2.6.tar.gz # cd DenyHosts-2.6 # python setup.py install The default is to install to the /usr/share/denyhosts directory. 2. Configure # cd /usr/share/denyhosts/# cp denyhosts.cfg-dist denyhosts.cfg # vi denyhosts.cfg PURGE_DENY = 50m #How long after clearing blocked IP HOSTS_DENY = /etc/hosts.deny #will block IP Write to hosts.deny BLOCK_SERVICE = sshd #block service name DENY_THRESHOLD_INVALID = 1 #Number of failed logins allowed for invalid users DENY_THRESHOLD_VALID = 10 #Number of failed logins for normal users DENY_THRESHOLD_ROOT = 5 #Number of failed logins allowed WORK_DIR = /usr/Local/share/denyhosts/data #Log the deny host or ip to Work_dir DENY_THRESHOLD_RESTRICTED = 1 #Set deny host Write to this folder LOCK_FILE = /var/lock/subsys/denyhosts #Write the pid record of DenyHOts to In LOCK_FILE, it is ensured that the service is started correctly, preventing multiple services from being started at the same time. HOSTNAME_LOOKUP=NO #Do you want to do domain name reversal ADMIN_EMAIL = #Set administrator email address DAEMON_LOG = /var/log/denyhosts #Own log file DAEMON_PURGE = 10m #This is the same as PURGE_DENY setting and also clears the time of hosts.deniedssh users . 3. Set the startup script # cp daemon-control-dist daemon-control # chown root daemon-control # chmod 700 daemon-control After executing daemon-contron start, you can. # ./daemon-control start If you want DenyHosts to start automatically after each restart, you need to do the following: # ln -s /usr/share/denyhosts/daemon-control /etc/init.d/denyhosts # chkconfig -- Add denyhosts # chkconfig denyhosts on Then you can start: # service denyhosts start You can see if there is a forbidden IP in /etc/hosts.deny, and some instructions have been successful.

Copyright © Windows knowledge All Rights Reserved