v1.7.1Web TerminalBSD-2-Clause

WebSocket-to-PTY bridge module for axil โ€” interactive browser terminal sessions over a login shell. Canonical header is <ttypt/axil-tty.h>.

GitHub
git clone https://github.com/tty-pt/axil-tty

Documentation

Manual Pages

axil-tty logo

axil-tty

npm C99 BSD-2-Clause PTY terminals

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)

OptionArgumentDescription
-maxil-ttyLoad the terminal bridge module
-pPORTHTTP/WS listen port (default: 8080)
-AnoneAuto-authenticate all connections (anonymous mode)
-dnoneRun in foreground (debug mode)

2. Security, Privilege Separation & Terminal Gating

When deployed in authenticated environments alongside axil-auth:

  1. Session & HMAC Ticket Verification: The /tty WebSocket endpoint validates the QSESSION cookie against in-memory corm session tables and, under axil -u USER privilege separation, verifies short-lived HMAC TTY tickets (<ttypt/axil-tty-privsep.h>).
  2. 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 enforces tty_privsep_policy_check_pw() / tty_privsep_validate_man_arg() and passes only the master PTY descriptor back to the unprivileged web worker over SCM_RIGHTS.
  3. Fail-Closed Shell & UID Gating: axil-tty inspects getpwnam(), refuses cross-UID shell spawns when running non-root, and rejects accounts whose shell is /bin/false or /sbin/nologin with HTTP 403 Forbidden before allocating a PTY. On Windows (_WIN32), telnet negotiation and browser terminal assets remain available while POSIX PTY spawning fails closed with ENOSYS.

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:

  • TerminalController manages @xterm/xterm lifecycle, FitAddon resizing, WebGL/canvas fallback, font readiness, and PTY event routing (with SSR/Node-safe dynamic @xterm/xterm loading across ESM axil-tty.js and CJS cjs/axil-tty.js).
  • createAxilTtyBridge (@tty-pt/axil-tty/bridge) and the standalone Web HAL capability module (htdocs/axil-tty-cap.js) register axil_tty_* and tty_* host imports plus stele: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.

Maintained by:tty-pt