# Relay Linux agent A Rust executable that opens a persistent, authenticated WSS connection to `re.eldento.com`. Each enrolled device receives a public URL: `https://.d.eldento.com`. ## Install and enroll In Relay, open **Devices → Add agent**. Generate a single-use enrollment code and run the displayed download command on the Linux device. Codes expire after 10 minutes and link the device to the signed-in Relay account. Linux x86-64 (including Ubuntu 22.04): ```sh curl -fL https://re.eldento.com/downloads/relay-agent-linux-amd64 -o relay-agent chmod +x relay-agent ./relay-agent YOUR_ENROLLMENT_CODE --name "My Linux device" ``` For ARM64, use `relay-agent-linux-arm64`. If you prefer wget: ```sh wget -O relay-agent https://re.eldento.com/downloads/relay-agent-linux-amd64 chmod +x relay-agent ./relay-agent YOUR_ENROLLMENT_CODE ``` Checksums are published at `https://re.eldento.com/downloads/SHA256SUMS`. Both binaries are statically linked for musl and do not require an installed Rust toolchain, shared OpenSSL, or a particular glibc version. The x86-64 binary is tested in an Ubuntu 22.04 container. Root access and inbound device ports are not required. Outbound HTTPS/WSS on TCP 443 is required. From version 0.3.2, connections to the default Relay server try the built-in IP `172.104.172.231` without DNS. A failed connection falls back to DNS after at most five seconds of connecting. HTTP Host, TLS SNI and certificate verification still use `re.eldento.com`. Custom server origins and forwarded target hosts use normal name resolution. Every reconnect tries the built-in IP first. When `/custom` is a directory, the agent stores its identity at `/custom/.config/relay-agent/identity.json`. Otherwise it uses `$XDG_CONFIG_HOME/relay-agent/identity.json` or `$HOME/.config/relay-agent/identity.json`. The file has permissions 0600 on Linux. On upgrade, an existing identity from the old default path is copied into the new location if it has no identity yet; the original is retained. `/custom` must be writable by the agent user. An explicit `--state` always takes precedence. Keep this file private. Use `--state /path/identity.json` to select another file. A later start needs no code: ```sh ./relay-agent ``` To enroll a separate device identity on the same machine, use another `--state` path. An existing identity is never silently overwritten. The enrollment code can also be provided through `RELAY_ENROLLMENT_CODE`. `--server` accepts a verified HTTPS origin and is intended for a separate Relay deployment. ## Configure forwarding Once the agent appears in **Devices**, open **Configure forwarding** and set: ```text https://192.168.101.99:8080 ``` A request to `https://.d.eldento.com/abc/xyz?q=1` goes to `https://192.168.101.99:8080/abc/xyz?q=1` from the device's network. HTTP methods, request bodies, query strings, response statuses, and ordinary headers are forwarded. Target URL base paths are supported and prepended to the request path. Configuration changes apply to subsequent requests without restarting the agent. **The forwarding URL is public.** Anyone with it can access the configured service. The agent deliberately accepts invalid/self-signed certificates on the configured HTTPS target. TLS certificate verification remains enabled for enrollment and the long connection to Relay. The target receives its own Host header, plus X-Forwarded-Host and X-Forwarded-Proto describing the public request. Hop-by-hop headers are removed. Absolute redirects to the configured target are rewritten to the device domain. Cookie Domain attributes are removed so cookies belong to the device domain. Response HTML, JavaScript, and embedded absolute URLs are not rewritten; a target application that hardcodes private URLs may need its external/base URL configured. Forwarding uses streamed binary-safe request and response bodies. Limits: - 64 MiB per request body; no configured response-size cap. - 32 active HTTP requests per agent; 256 globally. - Approximately 120 seconds per request, including long-lived response streams. - HTTP upgrades (including WebSocket), CONNECT, and indefinite SSE streams are not supported by the initial HTTP forwarding protocol. The agent reconnects automatically with backoff up to 30 seconds. The same identity retains its domain across reconnections. In-flight HTTP requests fail when the connection drops and are not replayed automatically. Disabled, offline, and unconfigured devices return HTTP 503. Revoked/unknown devices return 404. Revoking an agent disables its token; enroll a new identity to reconnect it. ## Run continuously with systemd First enroll as the Linux user that will run the service. Install the executable at `/usr/local/bin/relay-agent` (or use its actual absolute location): ```sh sudo install -m 755 relay-agent /usr/local/bin/relay-agent mkdir -p ~/.config/systemd/user cat > ~/.config/systemd/user/relay-agent.service <<'UNIT' [Unit] Description=Relay HTTP device agent After=network-online.target [Service] ExecStart=/usr/local/bin/relay-agent Restart=always RestartSec=5 [Install] WantedBy=default.target UNIT systemctl --user daemon-reload systemctl --user enable --now relay-agent ``` For this user service to run after logout or boot without a login, an administrator can enable lingering with `sudo loginctl enable-linger "$USER"`. Do not run the foreground agent and service with the same identity simultaneously: the newest connection replaces the older one. Logs: `journalctl --user -u relay-agent -f`. ## Build Rust 1.90 is used by the pinned Docker build. Dependencies are locked in Cargo.lock. ```sh docker build -t relay-agent:0.1.0 . docker create --name relay-agent-output relay-agent:0.1.0 docker cp relay-agent-output:/relay-agent ./relay-agent-linux-amd64 docker rm relay-agent-output ``` Build on a Linux x86-64 Docker host for the amd64 artifact. `build-arm64.sh` is a cross-build helper for the builder image, using Zig 0.14.1 and the Rust `aarch64-unknown-linux-musl` target. Its `/source` and `/out` mounts refer to this source directory and the desired output directory respectively. The Rust code is organized around portable Tokio/Reqwest networking. Native Windows/macOS release builds and service installers are not part of this release. ## Response replacements and traffic monitoring In **Configure forwarding**, add ordered literal or regex response-body rules, and optionally enable **Monitor HTTP traffic**. These run on the Relay server; existing agent binaries do not need updating. Text responses can be buffered up to 8 MiB for replacement; binary, partial, oversized, unsupported-encoding, or slow-to-rewrite responses pass through unchanged. See the public API docs for regex syntax and limits. **View traffic** shows authenticated captures of request and final response headers and bodies. Captures include credentials and cookies present in traffic. Each body is capped at 64 KiB, each header set at 16 KiB, with visible truncation and incomplete-transfer indicators. Retention is 24 hours, at most 500 requests per device and 2,000 across the server. Clear history removes captures; disabling monitoring stops recording but retains existing history until expiry. ## Browser SSH (agent 0.2.0+) Open **SSH keys** in Relay to upload an OpenSSH/PEM private key, rename/delete saved keys, or import keys from existing SSH command devices. Then choose **Devices → Open SSH terminal**. Select a key, SSH username, port, and host: `127.0.0.1` reaches the agent's own machine; other names/IPs are resolved and reached from the agent's network. The destination must already run SSH and accept the corresponding public key. The agent itself is not an SSH server. Private keys stay encrypted on the Relay server. The agent transports encrypted SSH bytes and never receives the key. Confirm the destination host fingerprint on first use; subsequent changes require explicit acceptance. Closing the browser terminal disconnects the session. Use tmux/screen for persistent remote work. HTTP forwarding and browser SSH are independent; HTTP need not be enabled. Upgrade by stopping the old process, replacing its binary, and restarting as the same Linux user with the same identity path. Run `./relay-agent` without a code for an existing identity. New enrollment uses `./relay-agent CODE` (legacy `--code CODE` and `RELAY_ENROLLMENT_CODE` remain supported). ## Command center Agent 0.3.0 adds direct background commands. Open Devices → Run command, or select the device in Command center. Commands run with `/bin/sh -c`, as the user running the agent, in its working directory. No SSH server or private key is required. The API is `POST /api/agents/DEVICE_ID/jobs` (plain-text command, or JSON `{"command":"pwd; ls;","timeout":300}`). Poll `/api/jobs/JOB_ID` for live output and completion. Each stream retains its first 4 MiB. Commands continue when the browser closes. A disconnected agent interrupts commands without retrying them. Timeouts and disconnects kill the command process group; deliberately detached processes can survive. Restart an upgraded agent with its existing identity. ### File transfers through the SSH gateway Agent 0.3.3 advertises `tcp-v2` for a negotiated 2 MiB TCP forwarding window (up from 512 KiB), retains compatibility with older brokers, and disables TCP packet coalescing on its control connection. A stalled control writer times out after 30 seconds and triggers automatic reconnection. Modern SCP (SFTP), legacy `scp -O`, and SFTP work through the gateway. Active transfers cannot resume across a dropped SSH connection; reconnect and retry the transfer.