VPS建站前的准备和优化

本文主要针对VPS建站提供一些常见的准备和优化操作,相关命令在Centos 7下测试通过,其他系统请酌情调整并更改,所有标红色的命令为需要输入或手动修改的内容,其他均为提示信息。

1、修改默认的SSH端口

为防止对SSH默认端口的暴力破解,我们有必要在VPS上更改默认的SSH端口号码,登录SSH后输入以下操作:

vi /etc/ssh/sshd_config

出现以下信息后按Insert进行修改:

# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
Port 22999         //将前面的注释#号删除,输入你想设置的端口,例如22999
#Protocol 2,1
#ListenAddress 0.0.0.0
#ListenAddress ::

修改完成后按Esc,输入以下命令保存并退出:

:wq

然后重启SSH服务:

service sshd restart

Stopping sshd: [ OK ]
Starting sshd: [ OK ]

2、防止SSH暴力破解

通过在VPS上安装DenyHosts实现对SSH暴力破解的阻止。详见http://denyhosts.sourceforge.net/

以下操作将在你的VPS上下载、解压、安装DenyHosts,并赋予开机自启权限并立即启动服务。

cd ~
wget http://soft.vpser.net/security/denyhosts/DenyHosts-2.6.tar.gz
tar -zxvf DenyHosts-2.6.tar.gz
cd DenyHosts-2.6
python setup.py install
cd /usr/share/denyhosts/
cp denyhosts.cfg-dist denyhosts.cfg
cp daemon-control-dist daemon-control
chown root daemon-control
chmod 700 daemon-control
./daemon-control start
echo “/usr/share/denyhosts/daemon-control start” >> /etc/rc.local

3、安装并配置防火墙

安装并启用防火墙:

yum -y install firewalld firewall-config
systemctl start firewalld.service
systemctl enable firewalld.service

配置并启用常见的HTTP、HTTPS、SSH端口:

firewall-cmd –permanent –zone=public –add-service=http
firewall-cmd –permanent –zone=public –add-service=https
firewall-cmd –permanent –zone=public –add-service=ssh

重启防火墙使修改生效:

firewall-cmd –reload

4、防御DDoS攻击

cd ~
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh

按Q键退出,然后编辑配置文件:

vi /usr/local/ddos/ddos.conf

修改为以下参数:

NO_OF_CONNECTIONS = 100

APF_BAN = 0

BAN_PERIOD = 36000

最后保存退出。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇