[root@sz-nginx02 ~]# lastb -n 50
help ssh:notty 218.17.149.227 Sun Jan 24 16:28 - 16:28 (00:00)
hdfs ssh:notty 218.17.149.227 Sun Jan 24 15:16 - 15:16 (00:00)
michael ssh:notty 59-120-151-118.h Sun Jan 24 15:03 - 15:03 (00:00)
mfs ssh:notty 59-120-151-118.h Sun Jan 24 14:20 - 14:20 (00:00)
hadoop ssh:notty 218.17.149.227 Sun Jan 24 14:03 - 14:03 (00:00)
media ssh:notty 59-120-151-118.h Sun Jan 24 13:40 - 13:40 (00:00)
guest ssh:notty 218.17.149.227 Sun Jan 24 12:50 - 12:50 (00:00)
a ssh:notty ec2-54-165-101-6 Sun Jan 24 11:57 - 11:57 (00:00)
grayson ssh:notty 218.17.149.227 Sun Jan 24 11:37 - 11:37 (00:00)
admin ssh:notty 212-83-174-199.r Sun Jan 24 11:06 - 11:06 (00:00)
ubnt ssh:notty 212-83-174-199.r Sun Jan 24 11:06 - 11:06 (00:00)
。。。。
tail -100 /var/log/secure
Jan 24 14:41:41 sz-nginx02 sshd[5497]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:42 sz-nginx02 sshd[5499]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:43 sz-nginx02 sshd[5501]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:44 sz-nginx02 sshd[5503]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:45 sz-nginx02 sshd[5505]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:46 sz-nginx02 sshd[5507]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:46 sz-nginx02 sshd[5509]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:41:47 sz-nginx02 sshd[5511]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:42:39 sz-nginx02 sshd[5513]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:42:40 sz-nginx02 sshd[5515]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:43:20 sz-nginx02 sshd[5517]: fatal: Read from socket failed: Connection reset by peer [preauth]
Jan 24 14:43:21 sz-nginx02 sshd[5519]: fatal: Read from socket failed: Connection reset by peer [preauth]
。。。。
防止ssh爆破攻击方式:
制作密钥,ssh-keygen
使用DenyHost,限制其他ip登录
DenyHost是python写的一个程序,它会分析sshd的日志文件,当发现重复的攻击时会记录IP到/etc/hosts.deny文件,从而达到自动屏蔽IP的功能。
现在安装:地址:http://denyhosts.sourceforge.net官网下载,对应系统的版本。
安装教程:《denyhost防止SSH暴力破解,保护你的linux》
http://www.myhack58.com/Article/48/66/2011/28833.htm
DenyHosts配置文件解析: vi /etc/denyhosts.cfg
SECURE_LOG = /var/log/secure #ssh 日志文件,如果是redhat系列是根据/var/log/secure文件来判断的。 #Mandrake、FreeBSD是根据 /var/log/auth.log来判断的,而SUSE则是用/var/log/messages来判断的。这些在配置文件里面都有很详细的解释。 HOSTS_DENY = /etc/hosts.deny #控制用户登陆的文件 PURGE_DENY = 30m #过多久后清除已经禁止的,空表示永久不清除 # 'm' = minutes # 'h' = hours # 'd' = days # 'w' = weeks # 'y' = years BLOCK_SERVICE = sshd #禁止的服务名,当然DenyHost不仅仅用于SSH服务,还可用于SMTP等等。 DENY_THRESHOLD_INVALID = 1 #允许无效用户失败的次数 DENY_THRESHOLD_VALID = 5 #允许普通用户登陆失败的次数 DENY_THRESHOLD_ROOT = 3 #允许root登陆失败的次数 HOSTNAME_LOOKUP=NO #是否做域名反解 ADMIN_EMAIL = #管理员邮件地址,它会给管理员发邮件 DAEMON_LOG = /var/log/denyhosts #DenyHosts日志文件存放的路径