zoukankan      html  css  js  c++  java
  • CentOS6.x基础工作环境配置

    CentOS6.x基础工作环境配置

     

    一、系统安装

    系统安装时采用最小化原则,只安装base services。安装完毕后首先运行yum update 更新系统,重启。

     

    二、基本系统配置

    1、同步系统时间

    ntpdate cn.pool.ntp.org;hwclock --systohc

    将系统时间同步写入crontab,每天零时自动校时。

    crontab -e

    0 * * * * ntpdate cn.pool.ntp.org;hwclock --systohc

     

    2、禁用不必要的系统服务

    chkconfig --level 0123456 cups off

    chkconfig --level 0123456 ip6tables off

    #如未启用nfs,则相关服务可以关闭

    chkconfig --level 0123456 netfs off

    chkconfig --level 0123456 nfslock off

    #如无邮件需求,则相关服务可以关闭

    chkconfig --level 0123456 postfix off

     

    3、删除不必要的系统用户

    /usr/sbin/userdel adm

    /usr/sbin/userdel lp

    /usr/sbin/userdel shutdown

    /usr/sbin/userdel halt

    /usr/sbin/userdel news

    /usr/sbin/userdel uucp

    /usr/sbin/userdel operator

    /usr/sbin/userdel games

    /usr/sbin/userdel gopher

    #如不使用ftp服务则删除ftp用户

    /usr/sbin/userdel ftp

    #如不使用同步服务则删除sync用户

    /usr/sbin/userdel sync

     

    4、处理/etc/sysctl.conf

    编辑/etc/sysctl.conf添加如下内容,保存退出。

    net.ipv4.tcp_max_syn_backlog = 4096  #限定SYN队列的长度

    net.ipv4.ip_forward = 0  #禁止ip转发功能

    net.ipv4.conf.all.send_redirects = 0  #禁止转发重定向报文

    net.ipv4.conf.default.send_redirects = 0

    net.ipv4.conf.all.rp_filter = 1  #打开反向路径过滤功能,防止ip地址欺骗

    net.ipv4.conf.default.rp_filter = 1

    net.ipv4.conf.all.accept_source_route = 0  #禁止包含源路由的ip

    net.ipv4.conf.default.accept_source_route = 0

    net.ipv4.conf.all.accept_redirects = 0  #禁止接收路由重定向报文,防止路由表被恶意更改

    net.ipv4.conf.default.accept_redirects = 0

    net.ipv4.conf.all.secure_redirects = 0  #只接受来自网关的“重定向”icmp报文

    net.ipv4.conf.default.secure_redirects = 0

    net.ipv4.icmp_echo_ignore_broadcasts = 1  # 禁止ICMP重定向

     

    更改文件属性

    chmod 600 /etc/sysctl.conf

     

    5、只允许root执行cron/at

    echo root > /etc/cron.allow

    echo root > /etc/at.allow

    chown root:root /etc/cron.allow

    chown root:root /etc/at.allow

    chmod 400 /etc/cron.allow

    chmod 400 /etc/at.allow

     

    6、修改系统Banner

    编辑 /etc/issue/etc/issue.net两个文件删除所有系统相关信息,建议改为“Welcome to Server”。

     

    7、处理/etc/hosts.equiv

    A、不需要/etc/hosts.equiv

    预先生成/etc/hosts.equiv文件,并且设置权限为0000,防止被写入"++"

    B、需要/etc/hosts.equiv

    ·文件属主确保为root,设置权限为0600,防止被写入"++"

    ·如果使用NIS或者NIS+的话,此文件中的组应该是容易管理的。

    ·信赖主机使用全名

    ·任何时候都不应该出现”+”字符

    ·文件中不要使用'!' '#'符号,因为在该文件中那并不表示注释信息

    ·文件开始字符不应该为'-'.,请查阅C8

    ·确保该文件的访问权限被设置成600

    ·在每次安装补丁程序或操作系统之后,都应该重新检查该文件夹的设置情况

     

    8、处理/etc/aliases

    修改/etc/aliases文件,注释掉decodegamesingresssystemtoormanager,在文件最后加入root: <填写管理员邮箱>,保存退出。使用/usr/bin/newaliases命令激活新配置。确保文件属主为root

     

    9、禁止ctrl+alt+del重启

    CentOS 6.x :

    编辑/etc/init/control-alt-delete.conf注释

    start on control-alt-delete

    exec /sbin/shutdown -r now "Control-Alt-Delete pressed"

    保存退出,重启后生效。

     

    CentOS 5.x :

    编辑/etc/inittab,注释

    ca::ctrlaltdel:/sbin/shutdown -t3 -r now 

    保存退出。执行/sbin/init q ,使设置生效。

     

    10、设置用户口令安全机制

    编辑 /etc/login.defs,修改如下内容

    PASS_MAX_DAYS   90 #口令需要修改的天数,根据实际情况设置

    PASS_MIN_DAYS   7 #口令不可修改的天数,根据实际情况设置

    PASS_MIN_LEN    7 #口令最小长度

    PASS_WARN_AGE   28 #警告期限

     

    11、禁止root直接登陆

    echo "console" > /etc/securetty

     

    12、修改/etc/rc.d/init.d目录中脚本文件权限,确保只有root帐号可以执行。

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

     

    13、禁止在/etc/passwd中包含个人信息

     

    14、调整history大小

    编辑/etc/profile,将HISTSIZE改为0或适当的值,保存退出。

    清空当前history,执行history -c 

    立即写入history,执行history -w 

     

    三、日常运维

    1、查找无明确属主的文件

    find / -nouser -nogroup

     

    2、查找所有用户可写文件和目录

    find / -type f -perm +002

    find / -type d -perm +002

     

    3、查找空口令用户,应该为空

    awk -F: '($2 == "") { print $1 }' /etc/shadow

     

    4、查找UID0的用户,应该只有root

    awk -F: '($3 == 0) { print $1 }' /etc/passwd

     

    5、检查/etc/profile,禁止$PATH含当前目录".",也可通过下面的命令查找

    echo $PATH | egrep '(^|:)(\.|:|$)'

     

    6、查找具有suidsgid权限的文件

    find / -perm -6000

     

    7、检查除/dev以外,是否有特殊的块文件

    find / \( -type b -o -type c \) -print | grep -v '^/dev/'

     

    四、重要文件及目录权限配置标准

    文件或目录名称

    所属

    权限

    /etc/passwd

    root:root

    -rw-r--r--

    /etc/shadow

    root:root

    -rw-r--r--

    /etc/group

    root:root

    -rw-r--r--

    /etc/hosts

    root:root

    -rw-r--r--

    /etc/services

    root:root

    -rw-r--r--

    /tmp

    root:root

    -rw-rw-rwt

    /var/tmp

    root:root

    -rw-rw-rwt

     

     

     

    五、其他

    1、安全配置基本原则

    只对外开放所需要的服务,关闭所有不需要的服务。对外提供的服务越少,所面临的外部威胁越小。

    将所需的不同服务分布在不同的主机上,这样不仅提高系统的性能,同时便于配置和管理,减小系统的安全风险。

     

    lykyl原创,转载请注明出处)
  • 相关阅读:
    eclipse用法和技巧
    eclipse常用快捷键集锦
    移动端input的虚拟键盘影响布局
    使用github page + Hexo搭建个人博客折腾记
    javascript数组的排序(sort,冒泡)
    响应式布局与媒体查询
    css属性选择器诸如Class^=,Class*= ,Class$=释义
    怎么预览 GitHub 项目里的网页或 Demo
    常见浏览器的兼容问题(一)
    jQuery常用交互效果
  • 原文地址:https://www.cnblogs.com/lykyl/p/2804564.html
Copyright © 2011-2022 走看看