Linux安全配置

it2022-05-09  33

注释掉系统不需要的用户和用户组

vi /etc/passwd

 

  #adm:x:3:4:adm:/var/adm:/sbin/nologin  #lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin  #sync:x:5:0:sync:/sbin:/bin/sync  #shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown  #halt:x:7:0:halt:/sbin:/sbin/halt  #uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin  #operator:x:11:0:operator:/root:/sbin/nologin  #games:x:12:100:games:/usr/games:/sbin/nologin  #gopher:x:13:30:gopher:/var/gopher:/sbin/nologin  #ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin #注释掉ftp匿名账号

vi /etc/group

 

  #news:x:9:13:news:/etc/news:  #adm:x:4:root,adm,daemon  #lp:x:7:daemon,lp  #uucp:x:14:uucp  #games:x:20:  #dip:x:40:

关闭系统不需要的服务

service acpid stop chkconfig acpid off        #停止服务,取消开机启动 #电源进阶设定,常用在 Laptop 上 service autofs stop chkconfig autofs off        #停用自动挂载档桉系统与週边装置 service bluetooth stop chkconfig bluetooth off      #停用Bluetooth蓝芽 service cpuspeed stop chkconfig cpuspeed off       #停用控制CPU速度主要用来省电 service cups stop chkconfig cups off          #停用 Common UNIX Printing System 使系统支援印表机 service ip6tables stop chkconfig ip6tables off       #禁止IPv6

 

禁止非root用户执行/etc/rc.d/init.d/下的系统命令

 

chmod -R 700 /etc/rc.d/init.d/*

 

 

关闭多余的虚拟控制台

系统默认定义了 6 个虚拟控制台,实际上,很多人一般不会需要这么多虚拟控制台的,修改/etc/inittab ,注释掉那些你不需要的。

vi /etc/inittab

 

  # Run gettys in standard runlevels  1:2345:respawn:/sbin/mingetty tty1  #2:2345:respawn:/sbin/mingetty tty2  #3:2345:respawn:/sbin/mingetty tty3  #4:2345:respawn:/sbin/mingetty tty4  #5:2345:respawn:/sbin/mingetty tty5  #6:2345:respawn:/sbin/mingetty tty6

服务器禁止ping

vi /etc/rc.d/rc.local

 

#在文件末尾增加下面这一行echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

 参数0表示允许 1表示禁止

 

 

三点防止被攻击

  1.阻止ping 如果没人能ping通您的系统,安全性自然增加了。  2.防止IP欺骗    编辑host.conf文件并增加如下几行来防止IP欺骗攻击。

      order bind,hosts      multi off      nospoof on   3.防止DoS攻击    对系统所有的用户设置资源限制可以防止DoS类型攻击。如最大进程数和内存使用数量等。

 

    例如,可以在/etc/security/limits.conf中添加如下几行:      * hard core 0      * hard rss 5000  #( 本行或许没用,man limits.conf 显示 maximum resident set size (KB) (Ignored in Linux 2.4.30 and higher)      * hard nproc 50    然后必须编辑/etc/pam.d/login文件检查下面一行是否存在。      session required /lib/security/pam_limits.so    上面的命令禁止调试文件,限制进程数为50并且限制内存使用为5MB。    经过以上的设置,您的Linux服务器已经可以对绝大多数已知的安全问题和网络攻击具有免疫能力,但一名优秀的系统管理员仍然要时刻注意网络安全动态,随时对已经暴露出的和潜在安全漏洞进行修补。

 

转载于:https://www.cnblogs.com/Alandre/p/3620922.html


最新回复(0)