WebSocket-to-PTY bridge module for axil โ interactive browser terminal sessions over a login shell. Canonical header is <ttypt/axil-tty.h>.
git clone https://github.com/tty-pt/axil-ttyDocumentation
Manual Pages
axil-tty
WebSocket-to-PTY bridge module for axil โ interactive browser terminal sessions over a login shell. Canonical header is<ttypt/axil-tty.h>.
๐ GitHub Repository: https://github.com/tty-pt/axil-tty
1. Quickstart
Start axil with the terminal bridge loaded:
axil -d -A -p 8080 -m axil-tty
Open http://localhost:8080/tty in your browser to access an interactive terminal connected to a login shell.
CLI Options (Inherited from axil)
| Option | Argument | Description |
|---|---|---|
-m | axil-tty | Load the terminal bridge module |
-p | PORT | HTTP/WS listen port (default: 8080) |
-A | none | Auto-authenticate all connections (anonymous mode) |
-d | none | Run in foreground (debug mode) |
2. Security, Privilege Separation & Terminal Gating
When deployed in authenticated environments alongside axil-auth:
- Session & HMAC Ticket Verification: The
/ttyWebSocket endpoint validates theQSESSIONcookie against in-memory corm session tables and, underaxil -u USERprivilege separation, verifies short-lived HMAC TTY tickets (<ttypt/axil-tty-privsep.h>). - Jailed PTY Spawner Worker (
SCM_RIGHTS): On POSIX,tty_privsep_start_with_key()isolates privileged PTY spawning (tty_privsep_request_shell(),tty_privsep_request_man(),tty_privsep_request_kill()) into a dedicated helper that enforcestty_privsep_policy_check_pw()/tty_privsep_validate_man_arg()and passes only the master PTY descriptor back to the unprivileged web worker overSCM_RIGHTS. - Fail-Closed Shell & UID Gating:
axil-ttyinspectsgetpwnam(), refuses cross-UID shell spawns when running non-root, and rejects accounts whose shell is/bin/falseor/sbin/nologinwith HTTP 403 Forbidden before allocating a PTY. On Windows (_WIN32), telnet negotiation and browser terminal assets remain available while POSIX PTY spawning fails closed withENOSYS.
3. Browser Terminal Integration (NPM)
Install via NPM
Install @tty-pt/axil-tty alongside the required peer dependencies:
npm config set @tty-pt:registry https://tty.pt/npm/
# In your web project:
npm install @tty-pt/axil-tty @xterm/xterm @xterm/addon-fit
# Or install globally for the terminal CLI:
npm install -g @tty-pt/axil-tty
Embed in Any Web Application
import { create, TerminalController } from "@tty-pt/axil-tty";
import { createAxilTtyBridge } from "@tty-pt/axil-tty/bridge";
const term = create(document.getElementById("terminal"), {
url: `ws://${location.hostname}:${location.port}/tty`,
sub: {
cols: 80,
rows: 24,
onOpen: () => console.log("Connected to terminal server"),
onClose: () => console.log("Disconnected"),
}
});
For Web HAL worker runtimes and custom lifecycle management:
TerminalControllermanages@xterm/xtermlifecycle, FitAddon resizing, WebGL/canvas fallback, font readiness, and PTY event routing (with SSR/Node-safe dynamic@xterm/xtermloading across ESMaxil-tty.jsand CJScjs/axil-tty.js).createAxilTtyBridge(@tty-pt/axil-tty/bridge) and the standalone Web HAL capability module (htdocs/axil-tty-cap.js) registeraxil_tty_*andtty_*host imports plusstele:tty_*runtime capability handlers (registerSteleMainHandler/registerSteleWorkerHandler) for WASM workers, preserving bounded session scrollback across DOM remounts.
4. C API Integration
#include <ttypt/axil-tty.h>
// Spawn a login shell on a WebSocket connection
call_axil_tty_shell(fd);
// Spawn a specific command over PTY
char *argv[] = { "/bin/bash", NULL };
call_axil_tty_exec(fd, argv);
// Check if connection is managed by this module
if (call_axil_tty_owns(fd)) {
// Handled by axil-tty
}
5. Installation & Build
Prebuilt Packages
Prebuilt packages are distributed on tty.pt across all 9 platforms: Linux (APT / Alpine / Arch / Fedora-RHEL), macOS (Homebrew), Windows (winget / Scoop / MSYS2), OpenBSD, and mobile static sysroots for Android (https://tty.pt/android/) and iOS (https://tty.pt/ios/ โ libaxil-tty.xcframework + SwiftPM). Follow the installation instructions and use libaxil-tty as the package name.
Build from Source
Builds use shared libstele rules (include ttypt/include.mk):
make # builds lib/libaxil-tty.so
make test # run in-tree test suite
sudo make install # install module and htdocs to system
License
BSD-2-Clause โ Copyright (c) 2026, Paulo Quirino <quirinpa@gmail.com>. See LICENSE.