linux安全监控和日志
一,使用logcheck
安装
apt-get install logcheck
编辑日期格式
4 # Controls the format of date-/time-stamps in subject lines:
5 # Alternatively, set the format to suit your locale
6
7 DATE="$(date +'%Y-%m-%d %H:%M')"
二,用nmap监控网络
安装
apt-get install nmap
简单使用
nmap 192.168.1.105
nmap localhost # 扫描自己的系统
nmap 192.168.199.172 192.168.199.160 # 同时扫描多个
nmap -p 22,80 localhost # 扫描特定端口
nmap -sn 192.168.1.0/24 # 跳过端口检测,只执行简单的ping来检查那些系统在开机运行
namp -O localhost # 识别目标系统的系统类型
nmap -sV localhost # -sV: Probe open ports to determine service/version info
[email protected]:~# nmap -O localhost
Starting Nmap 7.40 ( https://nmap.org ) at 2019-02-28 17:55 HKT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00017s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
631/tcp open ipp
3389/tcp open ms-wbt-server
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.7 - 3.10
Network Distance: 0 hops
OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.84 seconds
三,用glances监控系统
安装
apt-get install glances
# 安装完成后
cat /etc/default/glances
sed -i 's;false;true;' /etc/default/glances # 配置系统启动时运行
glances # 手动启动
pip install --upgrade glances # 可用于升级
窗口颜色显示
- 绿色:OK
- 蓝色:CAREFUL,小心
- 紫色:WARNING,警告
- 红色:CRITICAL,问题严重
其实颜色代码依据定义在配置文件中的默认阈值进行标注。
配置文件/etc/glances/glances.conf
常用选项:
- -t 指定刷新的时间秒数,如 glances -t 5
- -s 在系统上启动glances的客户端服务器模式
- -B 将其绑定到系统的ip地址,glances -s -B 192.168.1.199
- -c <IP> 访问远程系统上的glances
效果图
四,使用lynis
lynis -c # 启动扫描,会持续一段时间,取决于系统上可找到的软件包
扫描完成,会生成详细的概览信息。并且会生成报告在/var/log/lynis.log中,剩下的就是分析报告了。
grep Waring /var/log/lynis.log
grep Suggestion /var/log/lynis.log