This page is in English — onze technische documentatie voor ontwikkelaars en beheerders is in het Engels.

Relay Laatst gecontroleerd:

SSH through the Relay

Reach a machine's SSH server through your Viaalink Relay with a private alias and ProxyJump, with copy-paste ~/.ssh/config entries, plus what is and is not supported.

Which connection is this?

This page is about B. SSH client ↔ Relay ↔ device from Three Kinds of Connection: a machine publishes its SSH server as a private alias, and you reach it from your laptop with an ordinary SSH client that jumps through the Relay. Nothing about it is public.

What this gives you

A machine behind a router — an office PC, a NAS, a Raspberry Pi — can make its SSH server reachable through your Relay without opening any port on its own network. You then log in to it from anywhere with a normal ssh command.

The Relay supports this with private aliases: the machine publishes its SSH port under a name that exists only inside the Relay. Nobody on the internet can connect to it directly. Only a person who first logs in to the Relay with an approved key can reach it, and they then still have to log in to the machine itself.

text

The inner SSH session runs from your laptop to the machine’s own SSH server. The Relay only copies its bytes and cannot read them.

Before you start

  • Both the machine and your laptop need an SSH key that the Relay approves. Add each public key as described in Access Control and Security — through the public keys folder or under People › Users on /_relay/dashboard (the dashboard described here is in Relay v1.36.0 and later, and in the ASUSTOR package 0.62.7 and later).
  • The machine needs a running SSH server (for example OpenSSH on port 22).
  • Ask the Relay operator to turn off random alias names, so the alias keeps the name you choose:
yaml

With --bind-random-aliases on (the default), the Relay replaces the name with a random three-character one — TCP Alias: k3x:22 — and gives a new one on every reconnect. --force-requested-aliases makes the machine’s request fail instead of silently taking a random name when the name is already in use.

The examples use relay.example.com for your Relay, mybox for the alias, and alice for the user account on the machine.

Step 1: publish the machine’s SSH server as a private alias

A remote forward with a name and a port other than 80 or 443 becomes a private alias. Run one of these on the machine.

With OpenSSH

bash

-N keeps the connection open without asking for a session. Leave it out to see the Relay’s welcome text, which includes the line TCP Alias: mybox:22 (or the random name, when random aliases are on).

To keep it permanent, put it in the machine’s ~/.ssh/config:

ssh-config

Then start it with ssh relay-publish. OpenSSH does not reconnect by itself: run that command under your service manager with automatic restart. (SessionType none needs OpenSSH 8.7 or newer; on older versions remove the line and start it with ssh -N relay-publish.)

With the built-in client

The Relay binary contains a client that reconnects by itself:

bash
  • Use the four-part form name:port:host:port. The short forms mybox:22 and mybox:localhost:22 mean a web address pointing at local port 22, not an alias.
  • --no-auth skips any online sign-in, so your SSH key is the only credential — the right choice for your own Relay.
  • The Relay’s built-in client verifies the host key only when you pass --host-key-fingerprint (fingerprints are listed at /_relay/discovery). Without it, it prints a warning and does not check. The via CLI pins the key automatically when you enrol.
  • --reconnect is on by default; keepalive and reconnect timing are described in How the Relay Works.

Step 2: connect from your laptop

One-off command

bash

-J (ProxyJump) logs in to the Relay first, then asks it for a connection to mybox port 22 — the alias — and runs your SSH session through it.

Copy-paste ~/.ssh/config

ssh-config

Now ssh mybox, scp file mybox: and rsync -a dir/ mybox:dir/ all work. HostName mybox is the alias name, not a DNS name: the Relay resolves it, not your laptop. When the machine published a port other than 22 (-R mybox:2200:localhost:22), add Port 2200 to the mybox entry.

For OpenSSH versions without ProxyJump, use the older equivalent:

ssh-config

Alternative: a local port

If a tool cannot use a jump host, forward a local port to the alias and connect to that:

bash

Limiting who can reach an alias

By default, every key the Relay approves can open a connection to every alias: the keys of other people on the Relay too, not only yours. The machine’s own SSH login is then the only lock: anyone with an approved key can reach your machine’s login prompt and try to log in. On a Relay you share with other people, either keep the machine’s SSH login strict (keys only, no passwords) or limit the alias as described below.

To allow only specific keys, the operator turns on --tcp-aliases-allowed-users (tcp-aliases-allowed-users: true in config.yml), and the machine lists the allowed keys when it connects, as a remote command:

bash

Each entry is a key’s SHA256 hash as printed by ssh-keygen -lf ~/.ssh/id_ed25519.pub. The machine’s own key is added automatically; any allows every approved key. The Relay confirms the list in its welcome text: Allowed users for TCP Aliases set to: SHA256:... (self), SHA256:.... A key that is not on the list is refused before anything reaches the machine (ssh -J reports stdio forwarding failed).

This works with OpenSSH only: the built-in client cannot send remote commands. Once the operator turns the option on, it applies to every alias on the Relay: an alias whose machine sent no list is reachable by nobody, and that includes every alias published with the built-in client. Machines that use the built-in client must then switch to OpenSSH and send a list (tcp-aliases-allowed-users=any keeps the old behaviour for that alias).

What the Relay records

The Relay cannot read the SSH session, but it does know who used an alias. Its log records each login with the key’s SHA256 hash and the name of the approved key file (for example key_file: "alice-laptop.pub"), and each connection to an alias with the alias name and the time (event: "alias_connection", alias: "mybox:22"). A refused key is logged as channel_refused with the alias it asked for. IP addresses are stored only as a hash. With --log-to-client, the machine itself also gets a line Accepted connection -> mybox:22 for every connection, without saying whose it was.

A remote forward to localhost with a port other than 80 or 443 opens a public TCP port on the Relay instead of an alias:

bash

With --bind-random-ports on (the default), the Relay picks a random port from --port-bind-range and prints it in the welcome text (for example TCP: relay.example.com:41285). Anyone on the internet can then try to log in on that port, and your router or firewall has to let it through to the Relay. Prefer a private alias.

What is and is not supported

Supported
Reaching a machine’s SSH through a private alias with ssh -J, ProxyJump, ProxyCommand ... -W, or ssh -LYes
scp, sftp, rsync and anything else that runs over SSH, through the aliasYes
Restricting an alias to specific keysYes, with --tcp-aliases-allowed-users and OpenSSH on the machine
A shell on the Relay itselfNo. Logging in to the Relay (ssh -p 2222 relay.example.com) only shows the welcome text and your addresses; Ctrl-C closes it.
Reaching an alias without logging in to the RelayNo. Aliases are only reachable from an SSH connection to the Relay.
SSH certificates (certificate authorities) for logging in to the RelayNo. The Relay accepts plain public keys only.
Options in front of an approved key (from=, command=, restrict)No. The Relay reads the key and ignores its options.
Sending remote commands from the built-in clientNo. Use OpenSSH for tcp-aliases-allowed-users=....
Reaching an alias with via or the built-in clientNo. Neither can open a jump or a local port forward; use OpenSSH (ssh -J, ProxyJump or ssh -L).

Troubleshooting

  • The connection fails at once with Refused a channel (the Relay’s log names the alias with reason no such name), before the machine asks for a password: no alias with that exact name and port exists, or your key is not on its allowed list. Your session to the Relay stays up. Check the machine’s connection and the alias name it got (leave out -N to see the welcome text).
  • Permission denied at the Relay: the key you use for the jump is not approved on the Relay. The laptop’s key must be approved too, not only the machine’s.
  • Host key warning for mybox after the machine was reinstalled: that is the machine’s own SSH host key, stored in your ~/.ssh/known_hosts under the alias name. Remove the old entry with ssh-keygen -R mybox.