linux 服务器死机了,于是追查原因。
wade@koala:/var/log$ less boot.log
看不出异常
wade@koala:/var/log$ less dmesg
区别;(未明)
/var/log/boot.log --- System boot log
/var/log/dmesg --- print or control the kernel ring buffer
/var/log/messages
看看这个区别
担心有人hack,首先ps -ef 查看了是否有异常的进程。逐个排查,没发现。
wade@koala:~$ last
wade pts/0 14.*.*.* Sat Aug 16 22:50 still logged in
wade pts/0 14.*.*.* Sat Aug 16 10:47 - 11:20 (00:32)
看到登录的ip 登录的时间,登录的时长
wade@koala:/var/log$ less auth.log
Aug 10 00:48:10 koala sshd[58696]: refused connect from 116.10.191.175 (116.10.191.175)
Aug 10 00:48:10 koala CRON[37279]: pam_unix(cron:session): session closed for user wade
Aug 10 00:48:26 koala sshd[59316]: refused connect from 116.10.191.175 (116.10.191.175)
Aug 10 00:48:45 koala CRON[27541]: pam_unix(cron:session): session closed for user root
Aug 10 00:48:57 koala sshd[61072]: refused connect from 116.10.191.175 (116.10.191.175)
Aug 10 00:49:01 koala CRON[61923]: pam_unix(cron:session): session opened for user wade by (uid=0)
Aug 10 00:49:23 koala CRON[40733]: pam_unix(cron:session): session closed for user wade
Aug 10 00:49:32 koala sshd[62333]: refused connect from 116.10.191.175 (116.10.191.175)
可以看到有些拒绝的连接,并且来自与异常的地方
您查询的IP:116.10.191.175 |
|
想看看这些登录者都干了什么:
1984 mocha test --compilers coffee:coffee-script
1985 git status
1986 vim ~/.bashrc
1987 cd
1988 vim /etc/hosts
1989 last
1990 history
问题是:区分不哪些是异常登录的时间的命令记录。
于是:vim ~/.bashrc
export HISTTIMEFORMAT="%F %T "
之后的登录的敲的命令都可以记录如下,带了时间:
1019 2014-08-16 23:29:36 less messages
1020 2014-08-16 23:30:14 ufw status
1021 2014-08-16 23:30:16 sudo ufw status
1022 2014-08-16 23:31:49 sudo ufw status| wc -l
wade@koala:/var/log$ less ufw.log
才发现,原来防火墙抵御了很多攻击:
Aug 10 00:42:41 koala kernel: [2765854.251408] [UFW BLOCK] IN=eth0 OUT= MAC=08:9e:01:49:d7:d6:0c:da:41:15:7a:1c:08:00 SRC=117.57.221.187 DST=14.17.96.17 LEN=40 TOS=0x00 PREC=0x00 TTL=54 ID=4680 DF PROTO=TCP SPT=3045 DPT=80 WINDOW=16560 RES=0x00 ACK FIN URGP=0
Aug 10 00:42:44 koala kernel: [2765857.155576] [UFW BLOCK] IN=eth0 OUT= MAC=08:9e:01:49:d7:d6:0c:da:41:15:7a:1c:08:00 SRC=60.173.26.34 DST=122.13.170.232 LEN=40 TOS=0x00 PREC=0x00 TTL=106 ID=256 PROTO=TCP SPT=6000 DPT=8088 WINDOW=16384 RES=0x00 SYN URGP=0
Aug 10 00:42:57 koala kernel: [2765869.791424] [UFW BLOCK] IN=eth1 OUT= MAC=08:9e:01:49:d7:d7:60:eb:69:d2:36:f1:08:00 SRC=192.168.1.6 DST=192.168.1.7 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=34479 DF PROTO=TCP SPT=54874 DPT=4949 WINDOW=5840 RES=0x00 SYN URGP=0
有异常的ip,也有本地的ip(未明,待查)
wade@koala:/var/log$ sudo ufw status| wc -l
70
总结:除了有些异常ip成功登录了,没发现异常,于是改了密码,清理一些开放的端口。
另外,所有这些记录都是可以更改的,包括所有的log, 所有的登录历史,history 命令,都可以改。要是真聪明,这些log都查看不出。