On this page
What you need
- A VPS with Linux and systemd — Ubuntu or Debian, say — and root access over SSH.
- A free UDP port. Most people take 443: QUIC on it looks like the HTTP/3 of an ordinary website.
- A TLS certificate. A real one is better — for that you need a domain pointing at the server's IP. Without a domain a self-signed one will do, but then the client has to skip certificate checks or pin the certificate's fingerprint.
- A network that lets UDP through. If UDP is cut or throttled there, Hysteria2 won't help — you need a TCP protocol such as VLESS Reality.
Installation
- 1
Run the official script
As root, run:
On the serverbash <(curl -fsSL https://get.hy2.sh/)The script puts the program in
/usr/local/bin/hysteriaand creates the hysteria-server systemd service. Running the same script again updates Hysteria2. - 2
Write the config file
The settings live in
/etc/hysteria/config.yaml. What goes in it is in the next section. The file is YAML: indentation matters, and tabs are not allowed. - 3
Start the service
On the serversystemctl enable --now hysteria-server.serviceThe service starts now and after every reboot.
systemctl status hysteria-server.serviceshows its state,journalctl -u hysteria-server.serviceits log. - 4
Open the UDP port
If ufw is on:
ufw allow 443/udp. If your host has a firewall in its control panel, open the port there too — over UDP, not TCP. - 5
Build the link
The address, port and password make a
hysteria2://link — paste it into a client or show it as a QR code. The format is in the last section.
What goes in config.yaml
listen: :443— the port the server waits on. It is a UDP port.acme— the block for a real certificate: your domain under domains, your email under email. Hysteria2 obtains the certificate and renews it by itself; the domain must point at the server, and TCP port 80 or 443 must be free for the check.- tls — instead of
acme, for your own or a self-signed certificate: the certificate file's path under cert, the key's under key. The service doesn't run as root but as its own hysteria user, so the files must be readable by it. auth— how clients log in:type: password, with a long random password under password. It goes into the link too, so letters and digits are the easiest choice.masquerade— what someone who opens the server without the password sees:type: proxy, with a real website's url under proxy andrewriteHost: true. Then from outside the server answers like an ordinary website over HTTP/3.bandwidth— optional. Without it Hysteria2 manages its speed with the BBR algorithm. Set the line's speed and it holds that speed even under loss — set it honestly, at your real speed, or it will flood the line.- A self-signed certificate is made with
openssl req -x509 -nodes -newkey rsa:2048 -days 3650 -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -subj /CN=example.com, and the service gets access withchown hysteria /etc/hysteria/server.key /etc/hysteria/server.crt.
The hysteria2:// link
The format is: hysteria2://password@address:port/?sni=domain#name. The password comes before the @; special characters in it are encoded as in web addresses. Clients also understand the short hy2:// instead of hysteria2://. After the # comes the name the client shows in its list.
hysteria2://Kd83hQx2Vb7mZp@vpn.example.com:443/?sni=vpn.example.com#my-hy2With a real certificate, sni is the domain it was issued for. With a self-signed one, add insecure=1 — the client won't check the certificate. Pinning its fingerprint with pinSHA256 — the certificate's SHA-256 — is safer: then nobody on the way can swap the server.
Need several users? auth has other login types, such as userpass with a list of names and passwords. Then the link has the name and password separated by a colon before the @. For one or two devices of your own, a single password is enough.