CentOS 7中系统安全及应用详述(2)

CentOS 7中系统安全及应用详述

CentOS 7中系统安全及应用详述

CentOS 7中系统安全及应用详述

CentOS 7中系统安全及应用详述

3、历史命令的限制

历史命令查看与清除

history:查看历史命令

history -c:清除历史命令

[root@localhost ~]# history //查看历史命令 1 vim /ect/sysconfig/network-scripts/ifcfg-ens33 2 vim /etc/sysconfig/network-scripts/ifcfg-ens33 3 vim /ect/sysconfig/network-scripts/ifcfg-ens33 4 vim /ect/sysconfig/network-scripts/ifcfg-ens33 5 vim /ect/sysconfig/netwok-scripts/ifcfg-ens33 6 vim /etc/sysconfig/network-scripts/ifcfg-ens-33 7 vim /etc/sysconfig/network-scirpts/ifcfg-ens33 8 vim /etc/sysconfig/network-scripts/ifcfg-ens33 9 vim /etc/sysconfig/network-scirpts/ifcfg-ens33 10 vim /etc/sysconfig/network-scripts/ifcfg-ens33 11 service network restart 12 ifconfig 13 chattr +i /etc/passwd /etc/shadow 14 lsattr /etc/passwd /etc/shadow 15 chattr -i /etc/passwd /etc/shadow 16 lsattr /etc/passwd /etc/shadow 17 chattr +i /etc/passwd/ /etc/shadow 18 chattr +i /etc/passwd /etc/shadow 19 lsattr 20 lsattr /etc/passwd /etc/shadow 21 useradd siti 22 chattr -i /etc/passwd /etc/shadow 23 lsattr /etc/passwd /etc/shadow 24 useradd siti 25 passwd siti 26 history [root@localhost ~]# history -c //清除历史命令 [root@localhost ~]# history //查看历史命令 1 history

减少记录的命令条数

vim /etc/profile :系统环境变量配置文件今日其中更改历史命令记录条数

source /etc/profile:使更改的配置生效

[root@localhost ~]# vim /etc/profile

CentOS 7中系统安全及应用详述

CentOS 7中系统安全及应用详述

[root@localhost ~]# history //查看历史命令,这个时候设置并没有生效 1 history 2 vim /etc/profile 3 history [root@localhost ~]# source /etc/profile //输入命令,使更改的配置生效 [root@localhost ~]# history //再次查看历史命令 4 history //只显示一条命令

闲置自动注销

vim /etc/profile 配置文件中编辑添加闲置注销条目,并设定自动注销时间

export TMOUT=时间(单位:秒):设定限制注销时间条目

[root@localhost ~]# vim /etc/profile //进入编辑配置文件 pathmunge /usr/local/sbin after pathmunge /usr/sbin after # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in ...//省略部分内容... fi fi done unset i unset -f pathmunge export TMOUT=60 //添加设定条目 ~ :wq //保存退出 [root@localhost ~]# source /etc/profile //输入命令,使更添加的条目生效

设置完成后系统将在60秒后自动注销。注销时间可以根据自己的操作习惯设置。

注销时自动清空命令历史

vim ~/.basf_logout:用户环境变量配置文件

在用户环境变量文件中添加history -c、clear命令,可以使用户注销时自动清除历史命令与缓存,提高安全性。

[root@localhost ~]# cd /home //进入用户家目录 [root@localhost home]# ls //查看用户 siti st11 sun [root@localhost home]# cd st11 //进入到st11用户目录 [root@localhost st11]# ls -a //查看目录中隐藏文件是否有 .bash_logout配置文件 . .bash_logout .bashrc .config .ICEauthority .mozilla 模板 图片 下载 桌面 .. .bash_profile .cache .esd_auth .local 公共 视频 文档 音乐 [root@localhost st11]# vim .bash_logout //进入编辑配置文件 # ~/.bash_logout history -c //添加命令清除历史命令 clear //添加命令清除缓存 ~ ~ ~ :wq //保存退出 4、用户切换与提权

大多数 Linux 服务器并不建议用户直接以 root 用户进行登录。一方面可以大大减少因误操作而导致的破坏,另一方面也降低了特权密码在不安全的网络中被泄露的风险。

su 命令

su命令:切换用户

su - 命令:切换用户后直接到用户家目录

[root@localhost /]# su siti //切换到siti用户 [siti@localhost /]$ //进入siti用户 [siti@localhost /]$ su - root //切换到root用户,并回到家目录 密码: 上一次登录:三 8月 28 11:55:19 CST 2019从 192.168.144.1pts/0 上 [root@localhost ~]# //进入root用户,并在家目录下

PAM认证

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/960b94ed28ea5d1b2e729797423d24df.html