一、账户安全控制
1、常见的用户安全措施类型
1)禁止管理服务账户
进制管理服务账户登录计算机
2)禁用不常用账户
防止用户身份被冒充
3)避免弱口令
防止密码被穷举攻击
设置密码必须满足四分之三原则,外加一定长度不低于7位
A~Z
a-Z
0~9
符号
4)锁定账户密码文件
防止用户创建账户或者修改密码
5)删除无用用户
用户离职删除账户
2、配置账户安全
禁止用户登录系统
[root@centos05~]#usermod -s /sbin/nologin test
锁定用户
[root@centos05~]#usermod -L test
查看锁定状态
[root@centos05~]#passwd -S test
锁定账户
[root@centos05~]#passwd -l test
解锁用户
[root@centos05~]#passwd -u test
锁定账户密码文件
[root@centos05~]#chattr +i /etc/passwd /etc/shadow
查看锁定状态
[root@centos05~]#lsattr /etc/passwd /etc/shadow
解锁账户密码文件
[root@centos05~]#chattr -i /etc/passwd /etc/shadow
设置密码十天后过期
[root@centos05~]#chage -M 10 bob
用户下次登陆修改密码
[root@centos05~]#chage -d 0 bob
修改配置文件设置密码有效期
[root@centos05~]#vim /etc/login.defs
修改配置文件设置记录历史命令
[root@centos05~]#vim .bash_profile
[root@centos05~]#source .bash_profile
退出登录后自动清空历史
[root@centos05~]#vim .bash_logout
[root@centos05~]#source .bash_logout
限制记录历史命令
[root@centos05~]#vim /etc/profile
设置长时间不操作终端自动注销
[root@centos05~]#vim .bash_profile
二、su和sudo的使用
1、su命令作用和用户之间切换
1)su作用
管理员到普通用户之间相互切换使用
2)su特点
管理员切换到普通用户不需要输入密码
普通用户切换到管理员需要输入密码
2、su账户切换使用
切换账户,不修改宿主目录
[root@centos05~]#su bob
切换到普通用户宿主目录
[bob@centos5 root~]# su - bob
切换到管理员账户宿主目录
[root@centos05~]#su -
将允许使用su命令账户添加到wheel组中
[root@centos05~]#gpasswd -a bob wheel
配置pam身份验证
[root@centos05~]#vim /etc/pam.d/su
4、sudo
1)sudo的作用
授权普通用户执行管理员命令
2)sudo特点
授权执行命令
防止发生误操作
5、配置sudo授权bob用户执行管理员命令
修改sudo配置文件
[root@centos05~]#vim /etc/sudoers
将用户加入到组
[root@centos05~]#gpasswd -a bob wheel
查看授权命令信息
[root@centos05~]#sudo -l
禁用
[root@centos05~]#systemctl mask ctrl-alt-del.target
守护进程运行
[root@centos05~]#systemctl daemon-reload
生成grub引导菜单密码
[root@centos05~]#grub2-mkpasswd-pbkdf2
备份引导菜单
[root@centos05~]#cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
[root@centos05~]#cp /etc/grub.d/00_header /etc/grub.d/00_header.bak
修改grub引导菜单
[root@centos05~]# vim /etc/grub.d/00_header
重新生成引导菜单
[root@centos05~]#grub2-mkconfig -o /boot/grub2/grub.cfg
限制终端登录,允许两个终端登录
[root@centos05~]#vim /etc/securetty
安装jr
挂载Linux镜像
[root@centos05~]#Mount /dev/cdrom /mnt/
[root@centos05~]#tar zxvf /mnt/john-1.8.0.tar.gz -C /usr/src/
[root@centos05~]#cd /usr/src/john-1.8.0/
[root@centos05 john-1.8.0]#cd src/
修改用户为弱口令
[root@centos05~]# passwd tom
复制密码配置文件
[root@centos05~]#cp /etc/shadow ./1.txt
破解密码配置文件
[root@centos05~]#cd /usr/src/john-1.8.0/run/
[root@centos05 run]#./john /root/1.txt
切换CentOS-7.4镜像
安装nmap扫描工具
[root@centos05~]# yum -y install nmap
扫描类型
-sS:扫描半关闭服务
-sT:扫描TCP协议
-sU:扫描UDP协议
-sP:扫描icmp协议
-p0:跳过ping检测
扫描192.168.100.50主机开放的协议和端口
[root@centos05~]#nmap 192.168.100.50
扫描指定的端口号
[root@centos05~]#nmap -p 22 192.168.100.50
扫描一个网段
[root@centos05~]# nmap 192.168.100.*