Access Control and Security
Choose who may connect to your Viaalink Relay and who may open its addresses — open links, a password per link, approved device keys and invites, and IP and country rules.
Two questions
Access control on a Relay answers two separate questions:
- Who may connect to the Relay? Devices that publish an address and SSH clients that jump to a private alias — paths A and B on Three Kinds of Connection. They always need an approved SSH key.
- Who may open an address? Visitors — path C. By default anyone with the link; you can add a password to a link or limit the Relay to certain networks or countries.
Choose an access level
| Level | Protects | Who gets in | Set by | Good for |
|---|---|---|---|---|
| Open link (default) | Nothing beyond the address itself | Anyone who knows or guesses the address | — | Short demos, webhooks, things that are public anyway |
| Password per link | One web address | Visitors who type the user name and password | The device, when it publishes | Sharing with a few people; admin pages |
| Approved keys | The Relay itself: publishing and SSH | Devices and laptops whose public key you approved | The operator: keys folder or People › Users | Always on — every Relay |
| Join codes / Invites | The Relay itself, for new devices | A device that presents a valid join code, once | The operator: People › Join codes | Adding devices without copying keys by hand: the device runs the via relay add command the join code shows |
| Allowed keys per alias | One private alias | Only the keys the machine lists | The machine, when it publishes; the operator turns the option on | SSH to a machine that only some people may reach |
| Private address | One web address | Every approved key that logs in to the Relay, not visitors from the internet | The operator: Names › Make private | Internal tools for the people on your Relay |
| IP and country rules | Everything on the Relay | Connections from allowed networks or countries | The operator | Office-only Relays; keeping out regions you never serve |
The levels add up: a link can have a password and the Relay can allow only your country. None of them replace the login of the service behind the address — an admin page still needs its own login.
The Relay has no single sign-on and no login page of its own for visitors: a password per link uses the browser’s standard password prompt.
Open link
Without anything else, an address such as https://k3x.relay.example.com opens for anyone who has it. With random names on (--bind-random-subdomains, the default) the name is a random three-letter word that changes on every reconnect: that keeps casual visitors out, but it is not a password. Three letters are easy to guess. Add a password to anything that shows private data.
Password per link
A device can put a user name and password in front of the name it asks for (user:password@name). The Relay then asks every visitor of that address for them, with the browser’s password prompt, before any request reaches the device.
ssh -p 2222 -R '[admin:SecretPass123@myapp]:80:localhost:3000' relay.example.comThe square brackets are needed: without them OpenSSH stops with Bad remote forwarding specification. The quotes keep your shell from reading them.
- It works for web addresses only, not for public TCP ports or private aliases.
- It needs OpenSSH: the forward format of the built-in client (
-F) has no place for a password. - The password also applies to people who reach the address through the Relay, for example a private address.
- The Relay’s welcome text prints the address with the user name and password in it. Do not share that output.
- It is on by default (
--bind-http-auth); the operator can turn it off for the whole Relay with--bind-http-auth=false(bind-http-auth: falseinconfig.yml). - The password travels inside the device’s encrypted SSH connection, and visitors send it over HTTPS. Use a long, random one:
openssl rand -base64 24makes one.
Approved keys
Every device and every laptop that connects to the Relay logs in with an SSH key. Authentication is on by default (--authentication), and the Relay only accepts keys you approved.
Adding a key as a file
Approved keys live in the public keys folder:
- Linux:
/var/lib/viaalink-relay/pubkeys/ - Docker Compose:
./data/pubkeys/ - ASUSTOR NAS:
viaalink-relay-data/pubkeys/
Copy the device’s .pub file into it:
sudo cp ~/.ssh/id_ed25519.pub /var/lib/viaalink-relay/pubkeys/developer-alice.pubThe Relay re-reads the folder every 200 ms: a new key works at once, without a restart. To take access away, delete the file. A file may hold several keys, one per line, in authorized_keys format; options in front of a key (such as from= or command=) are ignored.
Adding a key in the browser
The dashboard described here is in Relay v1.36.0 and later, and in the ASUSTOR package 0.62.7 and later.
On the setup dashboard (/_relay/dashboard), People › Users lets you:
- paste someone’s existing public key, with a name;
- or generate a new key pair for someone with Generate & download key. The private key is downloaded by your browser and is not kept on the Relay.
A shared password instead of keys
--authentication-password lets devices log in with one password shared by everyone. It is off by default; keys are safer, because each device can be removed on its own.
Join codes (Invites)
Instead of copying a key yourself, you can let a device register its own key. Under People › Join codes, create a single-use join code (referred to as Invites in earlier releases). A join code is valid 15 minutes unless you choose 24 hours or 7 days, and works once. The device sends its public key together with the join code to the Relay (/_relay/register), and the key is approved.
The People section has two alternatives: a Registration key (under People › Registration key) that stays valid until you turn it off, and open registration, which lets any device that can reach the Relay register with just its public key — turn that on only on a closed network.
In release builds, license mode is always active and registration endpoints are available without extra flags.
To follow these steps on a laptop from start to finish, with every command to copy, see Lesson: your first device online.
Per-person names
The setting described here is in Relay v1.36.0 and later, and in the ASUSTOR package 0.62.6 and later.
Under People › Users, click Names on a person’s row to choose Short names (e.g. terminal.relay.example.com) or Names end in a suffix (terminal-<suffix>.relay.example.com).
Suffix choices: Their name (-<name>), Their id, a random code, or A value you type. Then Save names.
Names a device already holds stay until it reconnects.
Under People › Join codes, New join code has the same Names / Suffix fields, preselected to a suffix of the person’s name, taken from the code’s label. When set to a suffix, devices added with the registration key or open registration each get their own id as suffix. Two people can never have the same suffix.
Upgrading changes nothing: people without a setting keep short names.
Private addresses
The setting described here is in Relay v1.36.0 and later, and in the ASUSTOR package 0.62.3 and later.
On the dashboard, Names lists every web address on the Relay. Make private on a row turns that address into a private address:
- From the internet it answers exactly like an address nobody holds:
404 Not Found, the same headers, an empty body. A wildcard address on the Relay never answers for it either. Visitors cannot tell that it exists. - Through the Relay it still works for every device and person whose key the Relay approves. They reach it over their own SSH connection to the Relay, not as a visitor.
The device that publishes it changes nothing and keeps the address; its welcome text still prints the usual HTTP: and HTTPS: lines.
Opening a private address in a browser
There is no via command for this yet, and the built-in client cannot do it. Use OpenSSH with a local port forward to port 80 of the address:
ssh -p 2222 -N -L 8080:notes.relay.example.com:80 relay.example.comThe Relay only answers when the browser sends the address’s own name. Opening http://localhost:8080 gives 404 Not Found. Add the name to your computer’s hosts file, pointing at your own machine:
# /etc/hosts (Windows: C:\Windows\System32\drivers\etc\hosts)
127.0.0.1 notes.relay.example.comThen open http://notes.relay.example.com:8080 while the ssh command runs. The connection from your browser to your computer is plain HTTP, but it never leaves your computer; from there it travels inside your encrypted SSH connection. The app behind the address sees the name with the port (notes.relay.example.com:8080) as host. An app that builds its own links from that name keeps working; one that only accepts its configured name may need that name added.
Who can reach a private address
Every approved key can, whichever person it belongs to. A private address is private from the internet, not between the people on your Relay. When an address must be closed to some of them, give it its own login, or a password per link (that works through the Relay too).
A key that is removed from the approved keys, or a device you block, is refused at once, even on an SSH connection that was opened before. The refusal looks the same as for an address that does not exist.
Allowed keys per alias
By default, every approved key can reach every private alias; the machine’s own SSH login is the second lock. To allow only certain keys, the operator turns on --tcp-aliases-allowed-users, and the machine lists the allowed keys when it publishes. The option then holds for every alias on the Relay: an alias published without a list, which includes every alias published with the built-in client, is reachable by nobody. The steps are on SSH through the Relay.
IP and country rules
These rules apply to the whole Relay — web addresses, public TCP ports and SSH logins of devices alike. They cannot be set per address.
Blocking addresses
# In config.yml
banned-ips: 203.0.113.50,198.51.100.0/24Or on the command line:
viaalink-relay --banned-ips=203.0.113.50,198.51.100.0/24Allowing only some networks
whitelisted-ips: 192.0.2.0/24,198.51.100.12Once you list allowed addresses, everything else is blocked — including your own devices, if they connect from elsewhere. The machine itself (127.0.0.1, ::1) always stays allowed, so you cannot lock yourself out of the setup dashboard.
Countries
Country rules need --geodb turned on; without it they are ignored, and the Relay logs a warning.
geodb: true
banned-countries: CN,RU
whitelisted-countries: NL,BE,DEAddresses on your own network — loopback, the private ranges 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16, carrier-grade NAT and IPv6 unique-local addresses — are never judged by country, so allowing only your country does not block your office or home LAN.
Behind Caddy or another proxy
When running behind a reverse proxy (such as Caddy), pass --proxy-ssl-termination so the Relay knows TLS is terminated upstream, and list the proxy’s IP in --trusted-proxies (e.g. --trusted-proxies=127.0.0.1). Without --trusted-proxies, the Relay sees the proxy’s address instead of the visitor’s, and IP or country rules would evaluate the proxy instead of the real client.
A blocked visitor gets “403 Forbidden”; a blocked device cannot log in.
What the Relay can see
HTTPS ends at the Relay: it has to read a web request to know which device it belongs to. Whoever runs the Relay can therefore, in principle, see web traffic in the clear:
- Visitor to Relay: HTTPS, with the Relay’s Let’s Encrypt certificate.
- Relay to device: inside the device’s encrypted SSH connection.
- Device to local app: usually plain traffic on the same machine (
localhost).
When that is not acceptable, use TLS passthrough, so your own service holds the certificate, or publish something that encrypts by itself, such as SSH over a private alias. More in How the Relay Works.
TLS passthrough
With TLS passthrough the Relay reads only the name in the visitor’s TLS handshake and copies the encrypted bytes to the device. The visitor’s browser gets the certificate of your own service; the Relay never has its private key.
On the Relay, in config.yml:
sni-proxy: true # allow TLS passthrough forwards
sni-proxy-https: true # share them on the Relay's own HTTPS listener
bind-random-ports: false # keep the port the device asks forThe device then asks for the port of the Relay’s own HTTPS listener, the port in https-address: 8443 when your router translates 443 to it, 443 when the Relay listens there itself. That port must be in port-bind-range; the default (0,1024-65535) does not include 443, so in that case add it: port-bind-range: 443,1024-65535. When https-address names a host (127.0.0.1:8443), set tcp-address to the same host. When the port is not allowed, or bind-random-ports is on (the default), the forward lands on a random port instead (TLS: app.relay.example.com:42944), which only works when your router forwards that port to the Relay too. Turning bind-random-ports off also keeps the requested port for public TCP ports. When Caddy or another proxy ends HTTPS in front of the Relay, passthrough on the HTTPS port is not possible.
On the device, use OpenSSH: the built-in client and via cannot send sni-proxy=true. Leave out -N: it stops OpenSSH from sending that command, and the forward then becomes a private alias instead. With the Relay’s HTTPS listener on 8443:
ssh -p 2222 -R app:8443:localhost:9443 relay.example.com sni-proxy=trueThe Relay answers SNI proxy for TCP forwards set to: true and TLS: app.relay.example.com:8443. Here localhost:9443 is your own HTTPS service, with a certificate for app.relay.example.com. Visitors open https://app.relay.example.com; every other name on the Relay keeps the Relay’s certificate. A password per link cannot be used for such an address, since the Relay cannot read its requests.