全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别
查看: 1312|回复: 3

【VPS教程】【收集存档】

[复制链接]
发表于 2022-8-17 19:55:00 | 显示全部楼层 |阅读模式
本帖最后由 BZGOGO 于 2022-8-17 19:56 编辑

!!!!!!改root登录!!!!!!
一,甲骨文
echo root:要修改的密码 |sudo chpasswd root
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo service sshd restart
二,Azure
(Azure 里的 linux 模板应该是通过了 sshd_config 文件禁用了 Root 登陆,我们只需重新开启即可。
sudo su
vim /etc/ssh/sshd_config
# 在 sshd_config 文件里的 “Authentication” 部分加上以下内容
PermitRootLogin yes
# 完成以后退出 vim 并保存
service sshd restart # 重启 ssh 服务以应用更改
passwd root # 直接修改 Root 用户的密码

三,CDROM安装原版系统
apt-get install sudoapt-get install sudo
apt-get install vim
su root
vim /etc/ssh/sshd_config
编辑并保存: PermitRootLogin 设置为yes,PasswordAuthentication设置为yes
启动SSH服务器: /etc/init.d/ssh restart


!!!!!!甲骨文装BBR!!!!!!
centos7

grub2-mkconfig -o /boot/grub2/grub.cfg
wget -N "https://github.000060000.xyz/tcp.sh" && chmod +x tcp.sh && ./tcp.sh


Debian 9/10一键开启Google BBR (Ubuntu20适用)

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p


Oracle Cloud Ubuntu 20.04 防火墙设置

#Oracle控制面板开放端口
#这个论坛教程比较多,就不说了

#ROOT操作
sudo su

#处理预设规则
iptables -D INPUT -j REJECT --reject-with icmp-host-prohibited
iptables -D FORWARD -j REJECT --reject-with icmp-host-prohibited
/etc/init.d/netfilter-persistent save
/etc/init.d/netfilter-persistent reload
ufw enable #需要输入Y确认

#添加自定义规则
ufw allow 22/tcp #开放22/tcp端口
ufw allow 80,443/tcp #开放80/tcp和443/tcp端口
ufw allow 1234/udp #开放1234/udp端口
ufw reload #重载防火墙



关闭IPV4+IPV6双栈VPS的IPV6(实测Centos8永久关闭,debian9重启后失效)
编辑/etc/sysctl.conf,添加以下内容。

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
net.ipv6.conf.eth0.disable_ipv6=1

然后运行sysctl -p,测试curl ip.sb变成了ipv4。


CentOS/Debian/Ubuntu Linux修改SSH默认22端口
SSH服务器(sshd)作为Linux上非常重要的服务,安全性是很重要的,首先网上有很多专门的服务器用来扫描SSH默认的22端口并使用弱口令之类的密码字典进行暴力破解,虽然可以使用lnmp自带的denyhosts、fail2ban之类的安装脚本,但是将默认SSH端口改掉能过滤掉大部分SSH暴力破解的访问。该教程适合常见的CentOS/Fedora/RedHat、Debian/Ubuntu等常见的Linux发行版。
SSH服务器的配置文件为:/etc/ssh/sshd_config
具体修改步骤如下:
1、备份原sshd配置文件
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
2、修改sshd配置文件
可以使用winscp、nano、vim之类的软件编辑 /etc/ssh/sshd_config
查找Port 22,有可能 Port 22 是注释的(即前面有#号,有的话删掉 # 号)。
在 Port 22 下面添加一行 Port 3322  其中3322为你更改SSH后的端口。
这里建议先保留原来的22端口,待新的SSH端口测试正常工作后再删掉原Port 22 端口行。
修改完成后保存。
3、重启SSH服务器
重启SSH服务器命令:systemctl restart sshd
如果没有systemctl的话可以执行:/etc/init.d/sshd restart 或 /etc/init.d/ssh restart
如果没有报错的话就生效了,可以 ss -ntl 或 netstat -ntl 查看一下端口。
4、防火墙、安全组规则设置
iptables添加SSH新端口规则:
iptables -A INPUT -p tcp --dport 3322 -j ACCEPT             #3322替换为新的端口#
然后保存iptables规则
firewalld添加SSH新端口规则:
firewall-cmd --permanent --zone=public --add-port=3322/tcp             #3322替换为新的端口#
firewall-cmd --reload             #重载firewalld#
阿里云之类的安全组规则添加SSH新端口规则:
阿里云之类的有安全组之类设置的云服务器一定要在安全组规则里将新端口添加到“入方向”的允许规则。
5、putty、xshell之类的SSH软件连接测试
添加上新的SSH端口后一定要通过putty、xshell之类的SSH软件连接测试一下,测试可以正常连接然后再编辑 /etc/ssh/sshd_config 将Port 22 这一行直接删除或这一行前面加 # 注释掉,然后再按前面的命令重启SSHd服务。

FRP
Frps服务端一键配置脚本https://github.com/MvsCode/frps-onekey
教程https://www.yxtvs.com/2020/872.html
FRP和Nginx共用80端口  在/etc/nginx/conf/nginx.conf中http{ }里添加以下参数
server {

  listen 80;

  server_name *.abc.xyz;

  location / {

   proxy_pass http://127.0.0.1:81;

   proxy_redirect http://$host/ http://$http_host/;

   proxy_set_header X-Real-IP $remote_addr;

   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

   proxy_set_header Host $host;

  }

}

利用iptables设置端口转发
https://github.com/arloor/iptablesUtils
重启后不失效[Debian9测试]
apt install --assume-yes --no-install-recommends netfilter-persistent iptables-persistent && \
systemctl enable netfilter-persistent && systemctl status netfilter-persistent

iptables-save > /etc/iptables/rules.v4
iptables-restore < /etc/iptables/rules.v4

/usr/sbin/netfilter-persistent reload
/usr/sbin/netfilter-persistent restart


AZ100
https://cnblogs.com/kklldog/p/azure-free-12m.html
https://www.huing.cn/amp/16
https://51.ruyo.net/11319.html

AWS100
https://www.awseducate.com/student/s/awssite


Shadowsocks-libev
https://高墙.report/blog/ss_tutorial/zh/


DD
https://sunpma.com/137.html
https://blockxyz.notion.site/DD-fb837703b3ac4011bb2362e3a56ac148

win-wes7
wget --no-check-certificate -qO InstallNET.sh 'https://moeclub.org/attachment/LinuxShell/InstallNET.sh' && bash InstallNET.sh -dd 'http://vps0.net/natee/win/lite/wes7-x86-cn-lite/wes7-x86-cn-lite.vhd.gz'
账户:Administrator
密码:nat.ee

debian10-小内存需进VNC手动点回车
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') -d 10 -v 64 -p "自定义root密码" -port "自定义ssh端口"


VPS测试脚本
wget -O- bench.sh|bash
流媒体测试脚本
bash <(curl -L -s https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/check.sh)


告别国内VPS无法访问的github
修改本地host
既然上游服务器的域名地址被修改了,那我们直接在本地hosts文件了指定好域名对应的IP地址不就好了嘛
hosts 文件在每个系统的位置不一,详情如下:
• Windows 系统:C:\Windows\System32\drivers\etc\hosts
• Linux 系统:/etc/hosts
• Mac(苹果电脑)系统:/etc/hosts
• Android(安卓)系统:/system/etc/hosts
• iPhone(iOS)系统:/etc/hosts
然后将下面这些数据拷贝到自己电脑的hosts文件,再激活生效就可以了:

140.82.114.25                 alive.github.com
140.82.112.25                 live.github.com
185.199.108.154               github.githubassets.com
140.82.112.22                 central.github.com
185.199.108.133               desktop.githubusercontent.com
185.199.108.153               assets-cdn.github.com
185.199.108.133               camo.githubusercontent.com
185.199.108.133               github.map.fastly.net
199.232.69.194                github.global.ssl.fastly.net
140.82.112.4                  gist.github.com
185.199.108.153               github.io
140.82.114.4                  github.com
192.0.66.2                    github.blog
140.82.112.6                  api.github.com
185.199.108.133               raw.githubusercontent.com
185.199.108.133               user-images.githubusercontent.com
185.199.108.133               favicons.githubusercontent.com
185.199.108.133               avatars5.githubusercontent.com
185.199.108.133               avatars4.githubusercontent.com
185.199.108.133               avatars3.githubusercontent.com
185.199.108.133               avatars2.githubusercontent.com
185.199.108.133               avatars1.githubusercontent.com
185.199.108.133               avatars0.githubusercontent.com
185.199.108.133               avatars.githubusercontent.com
140.82.112.10                 codeload.github.com
52.217.223.17                 github-cloud.s3.amazonaws.com
52.217.199.41                 github-com.s3.amazonaws.com
52.217.93.164                 github-production-release-asset-2e65be.s3.amazonaws.com
52.217.174.129                github-production-user-asset-6210df.s3.amazonaws.com
52.217.129.153                github-production-repository-file-5c1aeb.s3.amazonaws.com
185.199.108.153               githubstatus.com
64.71.144.202                 github.community
23.100.27.125                 github.dev
185.199.108.133               media.githubusercontent.com

大部分情况下是直接生效,如未生效可尝试下面的办法,刷新 DNS:
• Windows:在 CMD 窗口输入:ipconfig /flushdns
• Linux 命令:sudo nscd restart,如报错则须安装:sudo apt install nscd 或 sudo /etc/init.d/nscd restart
• Mac 命令:sudo killall -HUP mDNSResponder
如果还没有生效的话,可以尝试重启一下电脑,毕竟这步操作可以解决 95 % 的电脑bug
崽崽 该用户已被删除
发表于 2022-8-18 08:54:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2022-8-18 10:03:03 | 显示全部楼层
好好好,正需要,谢谢
发表于 2022-8-20 06:06:26 | 显示全部楼层
  看起来很实用
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-26 19:37 , Processed in 0.061196 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表