一、安全注释掉系统不需要的设置用户和用户组cxu生命动力压片糖果【绿色动力】
注意:不建议直接删除,当你需要某个用户时,安全自己重新添加会很麻烦。设置cxu生命动力压片糖果【绿色动力】
cp /etc/passwd /etc/passwdbak #修改之前先备份cxu生命动力压片糖果【绿色动力】
vi /etc/passwd #编辑用户,安全在前面加上#注释掉此行 cxu生命动力压片糖果【绿色动力】
#adm:x:3:4:adm:/var/adm:/sbin/nologincxu生命动力压片糖果【绿色动力】
#lp:x:4:7:lp:/var/spool/lpd:/sbin/nologincxu生命动力压片糖果【绿色动力】
#sync:x:5:0:sync:/sbin:/bin/synccxu生命动力压片糖果【绿色动力】
#shutdown:x:6:0:shutdown:/sbin:/sbin/shutdowncxu生命动力压片糖果【绿色动力】
#halt:x:7:0:halt:/sbin:/sbin/haltcxu生命动力压片糖果【绿色动力】
#uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologincxu生命动力压片糖果【绿色动力】
#operator:x:11:0:operator:/root:/sbin/nologincxu生命动力压片糖果【绿色动力】
#games:x:12:100:games:/usr/games:/sbin/nologincxu生命动力压片糖果【绿色动力】
#gopher:x:13:30:gopher:/var/gopher:/sbin/nologincxu生命动力压片糖果【绿色动力】
#ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin #注释掉ftp匿名账号cxu生命动力压片糖果【绿色动力】
cp /etc/group /etc/groupbak #修改之前先备份cxu生命动力压片糖果【绿色动力】
vi /etc/group #编辑用户组,设置办公软件使用在前面加上#注释掉此行cxu生命动力压片糖果【绿色动力】
#adm:x:4:root,安全adm,daemoncxu生命动力压片糖果【绿色动力】
#lp:x:7:daemon,lpcxu生命动力压片糖果【绿色动力】
#uucp:x:14:uucpcxu生命动力压片糖果【绿色动力】
#games:x:20:cxu生命动力压片糖果【绿色动力】
#dip:x:40:cxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
二、关闭系统不需要的设置服务cxu生命动力压片糖果【绿色动力】
service acpid stop chkconfig acpid off #停止服务,取消开机启动 #电源进阶设定,安全常用在 Laptop 上cxu生命动力压片糖果【绿色动力】
service autofs stop chkconfig autofs off #停用自动挂载档桉系统与週边装置cxu生命动力压片糖果【绿色动力】
service bluetooth stop chkconfig bluetooth off #停用Bluetooth蓝芽cxu生命动力压片糖果【绿色动力】
service cpuspeed stop chkconfig cpuspeed off #停用控制CPU速度主要用来省电cxu生命动力压片糖果【绿色动力】
service cups stop chkconfig cups off #停用 Common UNIX Printing System 使系统支援印表机cxu生命动力压片糖果【绿色动力】
service ip6tables stop chkconfig ip6tables off #禁止IPv6cxu生命动力压片糖果【绿色动力】
####################################################################################################cxu生命动力压片糖果【绿色动力】
如果要恢复某一个服务,设置可以执行下面操作cxu生命动力压片糖果【绿色动力】
service acpid start chkconfig acpid on cxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
三、安全禁止非root用户执行/etc/rc.d/init.d/下的设置系统命令cxu生命动力压片糖果【绿色动力】
chmod -R 700 /etc/rc.d/init.d/*cxu生命动力压片糖果【绿色动力】
chmod -R 777 /etc/rc.d/init.d/* #恢复默认设置cxu生命动力压片糖果【绿色动力】
四、给下面的安全文件加上不可更改属性,从而防止非授权用户获得权限cxu生命动力压片糖果【绿色动力】
chattr +i /etc/passwdcxu生命动力压片糖果【绿色动力】
chattr +i /etc/shadowcxu生命动力压片糖果【绿色动力】
chattr +i /etc/groupcxu生命动力压片糖果【绿色动力】
chattr +i /etc/gshadowcxu生命动力压片糖果【绿色动力】
chattr +i /etc/services #给系统服务端口列表文件加锁,设置防止未经许可的删除或添加服务cxu生命动力压片糖果【绿色动力】
lsattr /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/services #显示文件的属性cxu生命动力压片糖果【绿色动力】
注意:执行以上权限修改之后,就无法添加删除用户了。安全美食市集活动cxu生命动力压片糖果【绿色动力】
如果再要添加删除用户,需要先取消上面的设置,等用户添加删除完成之后,再执行上面的操作cxu生命动力压片糖果【绿色动力】
chattr -i /etc/passwd #取消权限锁定设置cxu生命动力压片糖果【绿色动力】
chattr -i /etc/shadowcxu生命动力压片糖果【绿色动力】
chattr -i /etc/groupcxu生命动力压片糖果【绿色动力】
chattr -i /etc/gshadowcxu生命动力压片糖果【绿色动力】
chattr -i /etc/services #取消系统服务端口列表文件加锁cxu生命动力压片糖果【绿色动力】
现在可以进行添加删除用户了,操作完之后再锁定目录文件cxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
五、限制不同文件的权限cxu生命动力压片糖果【绿色动力】
chattr +a .bash_history #避免删除.bash_history或者重定向到/dev/nullcxu生命动力压片糖果【绿色动力】
chattr +i .bash_historycxu生命动力压片糖果【绿色动力】
chmod 700 /usr/bin 恢复 chmod 555 /usr/bincxu生命动力压片糖果【绿色动力】
chmod 700 /bin/ping 恢复 chmod 4755 /bin/pingcxu生命动力压片糖果【绿色动力】
chmod 700 /usr/bin/vim 恢复 chmod 755 /usr/bin/vimcxu生命动力压片糖果【绿色动力】
chmod 700 /bin/netstat 恢复 chmod 755 /bin/netstatcxu生命动力压片糖果【绿色动力】
chmod 700 /usr/bin/tail 恢复 chmod 755 /usr/bin/tailcxu生命动力压片糖果【绿色动力】
chmod 700 /usr/bin/less 恢复 chmod 755 /usr/bin/lesscxu生命动力压片糖果【绿色动力】
chmod 700 /usr/bin/head 恢复 chmod 755 /usr/bin/headcxu生命动力压片糖果【绿色动力】
chmod 700 /bin/cat 恢复 chmod 755 /bin/catcxu生命动力压片糖果【绿色动力】
chmod 700 /bin/uname 恢复 chmod 755 /bin/unamecxu生命动力压片糖果【绿色动力】
chmod 500 /bin/ps 恢复 chmod 755 /bin/pscxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
六、禁止使用Ctrl+Alt+Del快捷键重启服务器cxu生命动力压片糖果【绿色动力】
cp /etc/inittab /etc/inittabbakcxu生命动力压片糖果【绿色动力】
vi /etc/inittab #注释掉下面这一行cxu生命动力压片糖果【绿色动力】
#ca::ctrlaltdel:/sbin/shutdown -t3 -r nowcxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
七、健康饮食计划关闭多余的虚拟控制台cxu生命动力压片糖果【绿色动力】
我们知道从控制台切换到 X 窗口,一般采用 Alt-F7 ,为什么呢?因为系统默认定义了 6 个虚拟控制台,cxu生命动力压片糖果【绿色动力】
所以 X 就成了第7个。实际上,很多人一般不会需要这么多虚拟控制台的,修改/etc/inittab ,注释掉那些你不需要的。cxu生命动力压片糖果【绿色动力】
cp /etc/inittab /etc/inittabbakcxu生命动力压片糖果【绿色动力】
vi /etc/inittabcxu生命动力压片糖果【绿色动力】
# Run gettys in standard runlevelscxu生命动力压片糖果【绿色动力】
1:2345:respawn:/sbin/mingetty tty1cxu生命动力压片糖果【绿色动力】
#2:2345:respawn:/sbin/mingetty tty2cxu生命动力压片糖果【绿色动力】
#3:2345:respawn:/sbin/mingetty tty3cxu生命动力压片糖果【绿色动力】
#4:2345:respawn:/sbin/mingetty tty4cxu生命动力压片糖果【绿色动力】
#5:2345:respawn:/sbin/mingetty tty5cxu生命动力压片糖果【绿色动力】
#6:2345:respawn:/sbin/mingetty tty6cxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
八、删除MySQL历史记录cxu生命动力压片糖果【绿色动力】
用户登陆数据库后执行的SQL命令也会被MySQL记录在用户目录的.mysql_history文件里。cxu生命动力压片糖果【绿色动力】
如果数据库用户用SQL语句修改了数据库密码,也会因.mysql_history文件而泄漏。cxu生命动力压片糖果【绿色动力】
所以我们在shell登陆及备份的时候不要在-p后直接加密码,而是在提示后再输入数据库密码。cxu生命动力压片糖果【绿色动力】
另外这两个文件我们也应该不让它记录我们的操作,以防万一。cxu生命动力压片糖果【绿色动力】
cdcxu生命动力压片糖果【绿色动力】
cp .bash_history .bash_historybak #备份cxu生命动力压片糖果【绿色动力】
cp .mysql_history .mysql_historybakcxu生命动力压片糖果【绿色动力】
rm .bash_history .mysql_historycxu生命动力压片糖果【绿色动力】
ln -s /dev/null .bash_historycxu生命动力压片糖果【绿色动力】
ln -s /dev/null .mysql_historycxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
九、修改history命令记录cxu生命动力压片糖果【绿色动力】
cp /etc/profile /etc/profilebakcxu生命动力压片糖果【绿色动力】
vi /etc/profilecxu生命动力压片糖果【绿色动力】
找到 HISTSIZE=1000 改为 HISTSIZE=50cxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
十、隐藏服务器系统信息cxu生命动力压片糖果【绿色动力】
在缺省情况下,当你登陆到linux系统,它会告诉你该linux发行版的名称、版本、内核版本、服务器的名称。cxu生命动力压片糖果【绿色动力】
为了不让这些默认的信息泄露出来,我们要进行下面的操作,让它只显示一个"login:"提示符。cxu生命动力压片糖果【绿色动力】
删除/etc/issue和/etc/issue.net这两个文件,或者把这2个文件改名,效果是一样的。cxu生命动力压片糖果【绿色动力】
mv /etc/issue /etc/issuebakcxu生命动力压片糖果【绿色动力】
mv /etc/issue.net /etc/issue.netbakcxu生命动力压片糖果【绿色动力】
cxu生命动力压片糖果【绿色动力】
十一、服务器禁止pingcxu生命动力压片糖果【绿色动力】
cp /etc/rc.d/rc.local /etc/rc.d/rc.localbakcxu生命动力压片糖果【绿色动力】
vi /etc/rc.d/rc.local #在文件末尾增加下面这一行cxu生命动力压片糖果【绿色动力】
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_allcxu生命动力压片糖果【绿色动力】
参数0表示允许 1表示禁止cxu生命动力压片糖果【绿色动力】
投稿:请发邮箱 ruomao#hotmail.com (#换成@)
删稿:本站内容部分为会员转载,如需要删除请发至编辑邮箱处理!
建议:本站是养生门户网,分享的产品大多是食品为主,不能代替药物。有一定的调理作用,但不保证每个人食用后有同样的效果。分享的案例均转自互联网,如您有大病,建议您去看医生!我们理念是当下就要养生!
TAG:Centos安全设置