VPS安全配置基于Centos5.5_x86_64
#vi /etc/ssh/sshd_config #修改ssh端口和监听地址
找到
---------------------------------------------
#Protocol 2,1
#Port 22
#ListenAddress :
#PermitRootLogin yes
-------------------------------------------
修改为port大于1000以上的端口
Protocol 2 协议2更安全
port10009
ListenAddress 74.117.56.222
PermitRootLogin no #禁止root登录
一般的VPS都会有两个IP地址
一个专门做ssh ftp之类的监听用,一个用做web服务
#/etc/init.d/sshd restart #重启服务
设置权限
-------------------------------------------------------------------------------------
#chmod 750 /usr/bin/*cc*
#chmod 750 /usr/bin/*++*
#chmod 750 /usr/bin/*ld*
#chmod 750 /usr/bin/*as*
#chmod 700 /usr/bin/who
#chmod 700 /usr/bin/w
#chmod 700 /usr/bin/locate
#chmod 700 /usr/bin/whereis
#chmod 700 /bin/vi
#chmod 700 /usr/bin/vim
#chmod 700 /usr/bin/gcc
#chmod 700 /usr/bin/make
#chmod 700 /bin/rpm
#chmod 700 /usr/bin/yum
#chmod 700 /bin/cat
#chmod 700 /usr/bin/less
#chmod 700 /usr/bin/tail
#chmod 700 /usr/bin/head
-------------------------------------------------------------------------------------
密码安全
-----------------------------------------------------------------------------------
#vi /etc/login.defs
PASS_MIN_LEN 8 #修改为8
----------------------------------------------------------------------------------------
删除不用的账号
--------------------------------------------------------------------------------------------
#userdel news
#userdel lp
#userdel sync
#userdel shutdown
#userdel uucp
#userdel games
#userdel halt
-------------------------------------------------------------------------------------------------
history安全
-----------------------------------------------------------------------------------------
#chattr +a .bash_profile
#chattr +i .bash_profile
这个是避免删除.bash_history或者重定向到/dev/null
因此不能清除或者删除执行的命令
---------------------------------------------------------------------------------------------
删除版本信息
---------------------------------------------------------------------------------------
#rm -rf /etc/redhat-release
#rm -rf /etc/issue
登录信息可以在/etc/motd下设置
-----------------------------------------------------------------------------------------------
root邮件通知
------------------------------------------------------------------------------------------------
编辑vi .bashrc最后添加, 当有root权限的用户登录时发送邮件通知
echo 'ALERT -Root Shell Access(Server Name) on:' `date` `who` | mail -s "Alert:Root Access from `who cut -d`" (" -f2 |cut -d")" -f1`"your@email.com
--------------------------------------------------------------------------------------------------
今天就写这么多明天晚上继续更新
[ 本帖最后由 hackin 于 2010-7-17 23:48 编辑 ] PASS_MIN_LEN 8解释一下这是什么意思? SSH 我禁用root,用户生成KEY,只有KEY才能登录。
页:
[1]