在rockylinux9上安装hysteria2服务器
创始人
2026-05-30 14:35:46
0

一、安装准备

1. 更新 + 装依赖

dnf update -y
dnf install -y curl wget openssl firewalld
systemctl enable --now firewalld

2. 放行防火墙(443 UDP+TCP)

firewall-cmd --add-port=443/udp --permanent
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

二、安装 Hysteria2(官方脚本)

bash <(curl -fsSL https://get.hy2.sh/)

自动下载最新版、创建 systemd 服务

配置文件路径:/etc/hysteria/config.yaml

三、生成自签证书(无域名也能用)

openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) \
  -keyout /etc/hysteria/server.key \
  -out /etc/hysteria/server.crt \
  -subj "/CN=www.microsoft.com" -days 36500
chown hysteria:hysteria /etc/hysteria/server.*
chmod 600 /etc/hysteria/server.key

四、编写 config.yaml

vi /etc/hysteria/config.yaml

内容(格式:缩进用2个空格,:后有一个空格):

listen: :443
tls:
  cert: /etc/hysteria/server.crt
  key: /etc/hysteria/server.key
auth:
  type: password
  password: 你的密码  # ← 改成你的强密码
obfs:
  type: salamander
  salamander:
    password: 你的混淆密码 # 抹除协议特征的密码
masquerade:
  type: proxy
  proxy:
    url: https://www.microsoft.com  # 伪装成微软
    rewriteHost: true
bandwidth:
  up: 100 mbps
  down: 500 mbps
acl:
  inline:
    - reject(geoip:cn)
    - reject(all, udp/53)
  • masquerade:伪装成正常网站,降低被识别概率
  • bandwidth:限速,防被打

五、启动 + 开机自启

systemctl enable --now hysteria-server
systemctl status hysteria-server

看到 active (running) 就成功。

六、Windows 客户端

1、Hysteria2 官方 Windows 客户端(命令行版)

下载:https://github.com/apernet/hysteria/releases

配置文件(config.yaml,和exe放在一起)

server: 你的VPS_IP:443
auth: 你的密码 #和服务器的一样
obfs:
  type: salamander
  salamander:
    password: 你的混淆密码 #和服务器的一样
tls:
  sni: www.microsoft.com
  insecure: true
socks5:
  listen: 127.0.0.1:50000

双击exe运行,看到 connected 就成;浏览器、系统、其他软件,手动把代理改成 SOCKS5 127.0.0.1:50000 才能走流量 。

2、V2rayN(带界面,推荐新手)

下载:https://github.com/2dust/v2rayN/releases

✅ 配置要点

类型选 Hysteria2

地址:你的 VPS_IP:443

密码:和服务端一致

SNI:www.microsoft.com

勾选跳过证书验证

添加 Hysteria2 节点并启动后,可直接打开系统代理开关,全局流量会自动接管,浏览器、软件无需额外配置代理地址。

3、跳过证书验证,不安全,有下面两种方案升级:

(1)用域名 + 正规 TLS 证书

服务端配置:

listen: :443
acme:
  domains:
    - hy2.yourdomain.com  # 你的域名
  email: your@email.com

auth:
  type: password
  password: 你的密码

官方客户端配置:

server: hy2.yourdomain.com:443
auth: 你的密码 #和服务器的一样
obfs:
  type: salamander
  salamander:
    password: 你的混淆密码 #和服务器的一样
tls:
  sni: www.microsoft.com
  insecure: false
  serverName: hy2.yourdomain.com
socks5:
  listen: 127.0.0.1:50000

(2)无域名折中:自签名证书 + 绑定证书指纹(pinSHA256)

生成证书指纹:

openssl x509 -noout -fingerprint -sha256 -in /etc/hysteria/server.crt

输出类似:

SHA256 Fingerprint=AA:BB:CC:DD:...:ZZ

官方客户端配置:

server: 你的VPS_IP:443
auth: 你的密码 #和服务器的一样
obfs:
  type: salamander
  salamander:
    password: 你的混淆密码 #和服务器的一样
tls:
  sni: www.microsoft.com
  insecure: true
  pinSHA256: "AA:BB:CC:DD:...:ZZ"  # 上面复制的指纹
socks5:
  listen: 127.0.0.1:50000




上一篇:rockylinux9下安装postgresql及常用操作

下一篇:没有了

相关内容

在rockylinux9上...
一、安装准备1. 更新 + 装依赖dnf update -ydnf...
2026-05-30 14:35:46

热门资讯

vcenter因证书问题无法上... 解决方法:导入root CA证书。主要操作步骤如下:1、下载root CA证书,并解压。2、右击5a...
centos7支持中文 1、使用locale命令查看当前使用的语言2、使用locale -a 查看安装的语言包,如果没有中文...
centos7 LVM(逻辑卷... 一、LVM简介 LVM是 Logical Volume Manager(逻辑卷管理)的简写,它...
mariadb galera ... mariadb server下载地址:https://mariadb.org/download/?...
rockylinux 9中安装... 1、开启ipv4内核转发vi /etc/sysctl.conf,加入:net.ipv4.ip_for...
rockylinux9下安装p... 1、更新系统软件包dnf update2、安装PostgreSQLdnf install postg...
mysql用户管理 1、新建用户create user username@host identified by 'pa...
nginx配置实例:只允许内部... #配置清单location / { deny 192.168.1.1; ...
winddows使用syspr... 1、查看sidwhoami /user2、使用sysprep重新生成sid运行如下命令:打开“系统准...
GlusterFS部署和使用 官方网站:https://www.gluster.org/install/一、GlusterFS安装...