Linux VPS主机建站安全配置详解

  • A+
所属分类:VPS教程

基于CentOS6.64位系统的Vultr VPS服务器进行配置

Linux VPS主机建站安全配置详解

Vultr账户安全

Vultr登陆密码在网站后台直接修改点击Account--Authentication,密码设置复杂一些。

修改 VPS 的 Root的登陆密码

使用 ssh工具(xshell) 连接 VPS 之后,输入 passwd 命令。输入新密码是不显示出来的,Retype new password是在输入一次密码然后回车即可。如下图所示就说明密码已经成功修改。

修改SSH服务端口

vi /etc/ssh/sshd_config,
#使用命令进入ssh配置文件
找到#port 22,将前面的#去掉,然后修改端口 port 123(自己设定)
systemctl restart sshd
#重启ssh服务

 

DenyHosts防暴力攻击

DenyHosts是Python写的一个程序软件,运行于Linux上预防SSH暴力破解的,它会分析sshd的日志文件(/var/log/secure),当发现重复的攻击时就会记录IP到/etc/hosts.deny文件,从而达到自动屏IP的功能。

tar zxvf DenyHosts-2.6.tar.gz
#解压源码包                        
cd DenyHosts-2.6
#进入安装解压目录                                          
python setup.py install   
#安装DenyHosts                                
cd /usr/share/denyhosts/  
#默认安装路径                                
cp denyhosts.cfg-dist denyhosts.cfg
#denyhosts.cfg为配置文件                       
cp daemon-control-dist daemon-control 
#daemon-control为启动程序                    
chown root daemon-control  
#添加root权限                               
chmod 700 daemon-control 
#修改为可执行文件                                 
ln -s /usr/share/denyhosts/daemon-control /etc/init.d
#对daemon-control进行软连接,方便管理

安装到这一步就完成了。

/etc/init.d/daemon-control start
#启动denyhosts        
chkconfig daemon-control on 
#将denghosts设成开机启动

关闭系统自动更新

chkconfig --list yum-updatesd 
#显示当前系统状态
service yum-updatesd stop 
#关闭 开启参数为start
chkconfig --level 35 yum-updatesd off 
#禁止开启启动
chkconfig yum-updatesd off 
#禁止开启启动(所有启动模式全部禁止)
chkconfig --list yum-updatesd 
#显示当前系统状态

 

以上就是就是小九收集的一些Linux系统安全配置,如果有什么不足的,请大家补充。

bwg
小九

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: