Procy
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Pairing clients

Pairing installs a client with a one-liner. You create a pairing code on the server, run the generated command on the device, and the installer sets up rport with the right server address, fingerprint and credentials. The pairing service is built into rportd; it’s what the “Install client” dialog of the web UI uses.

Pairing: create a code in the web UI, run the one-liner on the device, the installer sets up rport, and the client connects

Enable pairing

Add a [pairing] section to /etc/rport/rportd.conf:

[pairing]
  enabled = true
  ## Public base URL of rportd used in the one-liners. Defaults to api.base_url,
  ## and without that to the scheme and host of each request.
  url = "https://procy.example.com"
  ## Where the installer downloads the client packages from. Required.
  downloads_url = "https://procy.example.com/downloads"
  ## How long a code stays valid. Defaults to 1h.
  #code_ttl = "1h"
  ## A code is invalidated by its first successful download. Set to true to allow reuse until it expires.
  #allow_code_reuse = false

Restart the server with sudo systemctl restart rportd.service.

When pairing is enabled, rportd serves these routes next to the API:

RouteAccessReturns
POST /pairingAPI administratorsa pairing code and the Linux and Windows one-liners
GET /pairing/<code>anyone with the codethe installer: PowerShell for PowerShell clients, shell otherwise
GET /pairing/updateanyonethe client update script

The status API reports <url>/pairing as pairing_url, so the web UI finds it without further setup. [server] pairing_url points the web UI at an external pairing service instead; it’s ignored while the built-in one is enabled.

Serve the client packages

The installer doesn’t download from GitHub. It expects the client packages under downloads_url in this layout:

<downloads_url>/rport/stable/VERSION
<downloads_url>/rport/stable/SHA256SUMS
<downloads_url>/rport/stable/rport_linux_<arch>.tar.gz
<downloads_url>/rport/stable/rport_windows_x86_64.zip

VERSION holds the version number, and SHA256SUMS the checksums of the archives; the installer stops if a download doesn’t match. Any static web server works, for example a folder under the doc_root of rportd. Without downloads_url the generated scripts refuse to run.

Pair a client

In the web UI, open “Install client”. The UI deposits the new client’s credentials with POST /pairing and shows the one-liners. On Linux:

curl https://procy.example.com/pairing/<code> > rport-installer.sh
sudo sh rport-installer.sh

On Windows, in PowerShell as Administrator:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url="https://procy.example.com/pairing/<code>"
Invoke-WebRequest -Uri $url -OutFile "rport-installer.ps1"
powershell -ExecutionPolicy Bypass -File .\rport-installer.ps1

The installer downloads and verifies the client, writes rport.conf, and installs and starts the service. The new client then connects and appears in the web UI.

You can also create a code through the API. It needs an administrator and client credentials that the server accepts, for example ones created with the /clients-auth endpoint:

curl -s -u admin:$PASSWORD https://procy.example.com/pairing \
  -H "Content-Type: application/json" \
  --data-raw '{
    "connect_url": "http://procy.example.com:8080",
    "fingerprint": "<FINGERPRINT>",
    "client_id": "client7",
    "password": "<CLIENT_PASSWORD>"
  }' | jq

The response holds pairing_code, expires and the one-liners in installers.linux and installers.windows.

Updating clients

GET /pairing/update returns the client update script: a shell script for curl/wget and PowerShell for Invoke-WebRequest. Run it as root (Linux) or as an administrator (Windows), on the machine or as a remote command from the web UI:

curl -fsS https://procy.example.com/pairing/update -o rport-update.sh && sudo sh rport-update.sh -n -m
Invoke-WebRequest -UseBasicParsing https://procy.example.com/pairing/update -OutFile rport-update.ps1
powershell -ExecutionPolicy Bypass -File .\rport-update.ps1 -m

The update is supervised, so a failed update does not leave a machine unreachable:

  1. The script downloads the latest client from downloads_url, verifies it against SHA256SUMS and backs up the current binary and rport.conf.
  2. A supervisor, started detached from the client (a systemd-run unit on Linux, a scheduled task or WMI process running as SYSTEM on Windows), stops the client, installs the new version and starts it again.
  3. The new client must log a connection to the server within 120 seconds and keep running for 20 more. If it does not, the supervisor restores the previous binary and config and restarts the client.

When the script runs as a remote command, it returns as soon as the supervisor has started; the client restarts a few seconds later. The outcome is written to /var/lib/rport-update/status.json on Linux and C:\Program Files\rport\update\status.json on Windows, next to an update.log. Windows also logs to the Application event log (source rport-update). status is success, rolled_back or rollback_failed.

Use -t for the unstable channel. To install a specific package, pass -z <url or file> on Linux (tar.gz, deb or rpm; set PKG_SHA256 to verify it) or -pkgUrl <url or file> on Windows.

Windows versions before Windows 11 and Server 2022 cannot use TLS 1.3. Keep tls_min in [api] at its default, "1.2", if you have such clients; with "1.3" they cannot download the installer, the update script or the client.

Security notes

  • A pairing code gives access to the client credentials embedded in the installer. Codes are 20 random characters, single-use by default and expire after code_ttl.
  • Codes are kept in memory. Restarting rportd invalidates all open codes.
  • Failed code lookups are rate-limited per IP address, and the responses are not cached.
  • Serve rportd, and therefore the pairing routes, over HTTPS.