1 / 15

课程简介

课程简介. Linux 网络安全应用. 课程简介. 系统安全常规优化 远程访问与 TCP Wrappers SELinux 介绍 iptable 防火墙应用 漏洞扫描与服务器性能监测. 第一 讲:账号安全设置. Linux 网络安全应用. 本章结构. 系统账号清理 使用 su 命令切换用户 使用 sudo 命令提升权限. 账号安全基本措施 3-1. 系统账号清理 将非登录用户的 Shell 设为 /sbin/nologin 锁定长期不使用的账号 删除无用的账号 锁定账号文件 passwd 、 shadow.

Download Presentation

课程简介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 课程简介 Linux网络安全应用

  2. 课程简介 • 系统安全常规优化 • 远程访问与TCP Wrappers • SELinux介绍 • iptable防火墙应用 • 漏洞扫描与服务器性能监测

  3. 第一讲:账号安全设置 Linux网络安全应用

  4. 本章结构 • 系统账号清理 • 使用su命令切换用户 • 使用sudo命令提升权限

  5. 账号安全基本措施3-1 • 系统账号清理 • 将非登录用户的Shell设为/sbin/nologin • 锁定长期不使用的账号 • 删除无用的账号 • 锁定账号文件passwd、shadow [root@localhost ~]# chattr +i /etc/passwd /etc/shadow [root@localhost ~]# lsattr /etc/passwd /etc/shadow ----i-------- /etc/passwd ----i-------- /etc/shadow 锁定文件并查看状态 [root@localhost ~]# chattr -i /etc/passwd /etc/shadow [root@localhost ~]# lsattr /etc/passwd /etc/shadow ------------- /etc/passwd ------------- /etc/shadow 解锁文件并查看状态

  6. 账号安全基本措施3-2 • 密码安全控制 • 设置密码有效期 • 要求用户下次登录时修改密码 适用于新建用户 [root@localhost ~]# vi /etc/login.defs …… PASS_MAX_DAYS 30 [root@localhost ~]# chage -M 30 lisi 适用于已有用户 [root@localhost ~]# chage -d 0 zhangsan 强制在下次登录时更改密码

  7. 账号安全基本措施3-3 • 命令历史限制 • 减少记录的命令条数 • 注销时自动清空命令历史 • 终端自动注销 • 闲置600秒后自动注销 [root@localhost ~]# vi /etc/profile …… HISTSIZE=200 [root@localhost ~]# vi ~/.bash_logout …… history -c clear [root@localhost ~]# vi ~/.bash_profile …… export TMOUT=600

  8. 使用su命令切换用户3-1 • 用途及用法 • 用途:Substitute User,切换用户 • 格式:su - 目标用户 • 密码验证 • root  任意用户, 不验证密码 • 普通用户  其他用户,验证目标用户的密码 [jerry@localhost ~]$ su - root 口令: [root@localhost ~]# whoami root 带 -选项表示将使用目标用户的登录Shell环境

  9. 使用su命令切换用户3-2 • 限制使用su命令的用户 • 启用pam_wheel认证模块 • 将允许使用su命令的用户加入wheel组 [root@localhost ~]# vi /etc/pam.d/su #%PAM-1.0 auth sufficient pam_rootok.so auth required pam_wheel.so use_uid …… [root@localhost ~]# gpasswd -a tsengyia wheel tsengyia 正在将用户“tsengyia”加入到“wheel”组中

  10. 使用su命令切换用户3-3 • 查看su操作记录 • 安全日志文件:/var/log/secure [root@localhost ~]# tail /var/log/secure …… May 13 18:05:51 mail su: pam_unix(su-l:session): session opened for user root by tsengyia(uid=1006) May 13 18:07:34 mail su: pam_unix(su-l:session): session opened for user jerry by tsengyia(uid=1006)

  11. 使用sudo机制提升权限4-1 • 用途及用法 • 用途:以其他用户身份(如root)执行授权的命令 • 用法:sudo 授权命令 • 密码验证 • 初次执行sudo命令时,验证当前用户的密码 • 不需验证目标用户的密码 [root@localhost ~]# sudo -u jerry /bin/touch /tmp/test.file [root@localhost ~]# ls -l /tmp/test.file -rw-r--r-- 1 jerry jerry 0 07-12 05:39 /tmp/test.file 使用-u 选项指定目标用户,缺省则为root

  12. 使用sudo机制提升权限4-2 • 配置sudo授权 • visudo或者 vi /etc/sudoers • 记录格式:用户 主机名列表=命令程序列表 [root@localhost ~]# visudo …… %wheel ALL=NOPASSWD: ALL jerry localhost=/sbin/ifconfig syrianer localhost=/sbin/*,!/sbin/ifconfig,!/sbin/route Cmnd_Alias PKGTOOLS=/bin/rpm,/usr/bin/yum mike localhost=PKGTOOLS 可以使用通配符*、取反符号! 类似别名还包括: User_Alias、Host_Alias

  13. 使用sudo机制提升权限4-3 • 查看sudo操作记录 • 需启用 Defaultslogfile 配置 • 默认日志文件:/var/log/sudo [root@localhost ~]# visudo …… Defaults logfile = "/var/log/sudo" [root@localhost ~]# tail /var/log/sudo …… May 13 09:49:47 : jerry : TTY=pts/0 ; PWD=/home/jerry ; USER=root ; COMMAND=/sbin/ifconfig eth0:0 192.168.1.11/24 May 13 10:12:18 : syrianer : TTY=pts/0 ; PWD=/home/syrianer ; USER=root ; COMMAND=list 启用日志配置以后,sudo操作过程才会被记录

  14. 使用sudo机制提升权限4-4 • 查询授权的sudo操作 • sudo -l 初次使用sudo时需验证当前用户的密码 [syrianer@localhost ~]$ sudo -l [sudo] password for syrianer: …… User syrianer may run the following commands on this host: (root) /sbin/*, (root) !/sbin/ifconfig, (root) !/sbin/route [syrianer@localhost ~]$ sudo /sbin/fdisk -l …… Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 10443 83778975 8e Linux LVM 默认超时为5分钟,在此期间不再重复验证

  15. 案例 • 需求描述 • 用户harry、jerry、tom可以管理用户账号 • 实现思路 • 用户harry、jerry、tom加入到managers组 • 配置sudo文件,增加对managers组的useradd、usermod、passwd等命令的权限

More Related