针对腾讯云轻量服务器的调教方案
既然要调教当然要有一些预备工作。忽略非Linux,以Debian或Ubuntu系统为例)
选择性开放防火墙端口
在服务器面板可以找到选择性打开(看你自己的需要)默认CVM开放,轻量不开放
净化系统
A方案: 上手直接DD干净系统(国内小鸡带宽水管小,耗时比较长)
DD自己找啦,论坛那么多……
1
|
关键词:萌咖 cxthhhhh.com bohanyang......
|
其实DD方案都差不多,原理就那几个,对于境外地区随便用都行,只要源纯净就可以了的。
但是对于境内。确实要找一个好点的源(大陆内的)避免水土不服(带宽小+DNS污染)
推荐用论坛MJJ提供的 @嗷嗷 https://haoduck.com/
(其实就是把镜像源放在国内方便下载)
1
2
|
bash <(curl -sL haoduck.com/sh/dd.sh)
#按照脚本提示选择并记住初始密码
|
B方案:莫怕直接用默认,干腾讯云监控&更换稳定源就行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#直接复制粘贴全部到SSH窗口即可
sudo -i
systemctl stop tat_agent
systemctl disable tat_agent
/usr/local/qcloud/stargate/admin/uninstall.sh
/usr/local/qcloud/YunJing/uninst.sh
/usr/local/qcloud/monitor/barad/admin/uninstall.sh
rm -f /etc/systemd/system/tat_agent.service
rm -rf /usr/local/qcloud
rm -rf /usr/local/sa
rm -rf /usr/local/agenttools
rm -rf /usr/local/qcloud
process=(sap100 secu-tcs-agent sgagent64 barad_agent agent agentPlugInD pvdriver )
for i in ${process[@]}
do
for A in $(ps aux | grep $i | grep -v grep | awk '{print $2}')
do
kill -9 $A
done
done
|
检验:TOP查看,控制面板监控仪表盘是否有记录,控制面板修改密码是否失效(失效就对了)同时也干掉腾讯云自家自带的监控报警功能(具体哪一个不知道,但是监控本身会互相唤醒守护…有点蛋疼)
更换稳定镜像
我们需要更换清华稳定的源(腾讯自家的一言难尽)官方的也行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#直接复制粘贴全部到SSH窗口即可
#批量修改源为清华
sources="/etc/apt/sources.list"
cat>"${sources}"<<EOF
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
EOF
apt-get -y update
#这里可以一齐更新你要的软件包一些依赖和环境必备的,看需要把因人而异。
#apt-get -y update && apt-get -y AAAAA BBBBB CCCCC
|
换完后记得可以更新下,update下一些软件包和系统本身
更换靠谱的公共DNS(自选非强迫)
大陆首选
1
2
3
4
5
6
7
|
#直接复制粘贴全部到SSH窗口即可
sed -i '$a\prepend domain-name-servers 223.5.5.5,119.29.29.29,223.5.5.5,183.60.83.19;' /etc/dhcp/dhclient.conf
sed -i '$a\dhclient' /etc/dhcp/dhclient.conf
## 或
sed -i '$a\prepend domain-name-servers 1.0.0.1,8.8.8.8,1.1.1.1,8.8.4.4;' /etc/dhcp/dhclient.conf
sed -i '$a\dhclient' /etc/dhcp/dhclient.conf
|
重启后的DNS就不用改啦
更换密码
1
2
3
4
|
passwd
(输入密码)
(输入密码)
#或者直接用秘钥(清爽)
|
修改端口
1
2
3
4
|
#方法众多,推荐懒人脚本
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/ssh_port.sh && chmod +x ssh_port.sh && bash ssh_port.sh
#改完后删除原先的
./ssh_port.sh end
|
使用fail2ban简易封禁SSH爆破
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#以Debian为例(别的可以依葫芦画瓢)
#安装
apt-get install fail2ban
#直接复制粘贴全部到SSH窗口即可
#配置参数
fail2ban="/etc/fail2ban/jail.d/sshd.local"
cat>"${fail2ban}"<<EOF
[ssh-iptables]
enabled = true
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
logpath = /var/log/auth.log # 如果是Centos路径要改/var/log/secure这个
maxretry = 9 # 最多连接9次失败
bantime = 777600 # 禁止9天(按秒单位1天86400)
EOF
#启动&开机自启
systemctl start fail2ban.service
systemctl enable fail2ban.service
|
开启BBR
直接用默认BBR(和最新版我感觉没差所以就偷懒了)
1
2
3
4
5
|
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
#检查是否BBR成功
sysctl net.ipv4.tcp_available_congestion_control
|