步骤一:查看 audit 目前生效的所有配置
/sbin/auditctl -s
步骤二:查看 audit 目前生效的所有规则
/sbin/auditctl -l
步骤三:生成 audit 报告
/sbin/aureport
/sbin/auditctl -s
/sbin/auditctl -l
/sbin/aureport
-w <command> -p x -k <search_key>
(
补充:
1) 这里的 <command> 是要监控的命令
2) 这里的 <search_key> 是个标识,用于简化在 audit 日志里搜索此命令
)
-w /usr/bin/rm -p x -k rm_command
(
补充:这里以
1) 监控 /usr/bin/rm 命令
2) 标识是 rm_command 为例
)
# augenrules
# service auditd restart
# auditctl -l
# ausearch -k rm_command
(补充:这里以查看标识为 rm_command 的 audit 日志为例)
https://access.redhat.com/solutions/3401281
mount error(13) permission denied
# dmesg
......
在使用 spawn 参数之前,要先安装 expect
设置 expect 参数等待执行的时间 (默认是 30 秒) 或者其它变量
#!/bin/bash
set timeout 30
或者:
#!/usr/bin/expect
set timeout 30
(补充:这里以设置 expect 参数的等待时间为 30 秒为例)
脚本开始根据出现的输出自动执行命令
#!/bin/bash
expect << EOF
spawn ssh mingyuzhu@10.0.0.1
expect "password:" {send "123\r"}
expect ">" {send "\r"}
EOF
或者:
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {"password:" {send "123\r"}}
expect eof
(补充:这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器,同时当输出的最后的字段是 “password:” 时自动输入 “123” 并回车为例)
后面接预期出现的内容。可以跟 send 参数配合,实现出现预期内容后执行什么命令,也可以不跟 send 参数配合只是出现什么内容后直接退出
#!/bin/bash
expect << EOF
spawn ssh mingyuzhu@10.0.0.1
expect "password:" {send "123\r"}
expect ">" {send "\r"}
EOF
或者:
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {"password:" {send "123\r"}}
expect eof
(补充:这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器,同时当输出的最后的文本是 “password:” 时自动输入 “123” 并回车为例)
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {
\"Linux*\" { exit 200 }
timeout { exit 100 }
incorrect { exit 100 }
eof { exit 100 }
}
return $?
interact
expect eof
(
补充:
1) 这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器
2) 同时当输出的最后的文本是以 “Linux” 开头时,返回值是 200,超市或其他的返回值是 100
3) 并最后将控制权还给用户为例
)
后面接要执行的命令。当预期出现的内容出现后,执行这些命令
#!/bin/bash
expect << EOF
spawn ssh mingyuzhu@10.0.0.1
expect "password:" {send "123\r"}
expect ">" {send "\r"}
EOF
或者:
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {"password:" {send "123\r"}}
expect eof
(补充:这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器,同时当输出的最后的字段是 “password:” 时自动输入 “123” 并回车为例)
代表结束所有,如果没有 EOF 的话最后的命令可能不会执行完
#!/bin/bash
expect << EOF
spawn ssh mingyuzhu@10.0.0.1
expect "password:" {send "123\r"}
expect ">" {send "\r"}
EOF
或者:
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {"password:" {send "123\r"}}
expect eof
(补充:这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器,同时当输出的最后的字段是 “password:” 时自动输入 “123” 并回车为例)
代表结束自动交互,就是把控制权交给用户
#!/bin/bash
expect << EOF
spawn ssh mingyuzhu@10.0.0.1
expect "password:" {send "123\r"}
expect ">" {send "\r"}
EOF
或者:
#!/usr/bin/expect
spawn ssh mingyuzhu@10.0.0.1
expect {"password:" {send "123\r"}}
expect eof
(补充:这里以使用 mingyuzhu 用户通过 SSH 登录 IP 地址为 10.0.0.1 的服务器,同时当输出的最后的字段是 “password:” 时自动输入 “123” 并回车为例)
SIOCADDRT: File Exists
确保以下目录中,网卡配置文件的 IP 地址只出现过了 1 次
/etc/sysconfig/network-scripts