# Module — Terminal

**Type**: Optional (disabled by default)

Interactive SSH terminal in the browser. Connects to the Proxmox host (or any SSH-accessible target) and opens a full PTY session via WebSocket.

## Features

- Full PTY support (`xterm-256color`, interactive shell)
- Responsive resizing — the terminal adjusts when the browser window is resized
- Terminal theme matches the panel's Neumorphism dark/light design
- Audit log entry on open and close

## WebSocket Endpoint

`GET /ws/terminal?token=<jwt>&host=<optional-override>`

If `host` is not specified, the SSH host configured during installation is used.

### Message Format

**Client → Server** (keyboard input): raw binary bytes

**Client → Server** (resize event): JSON text frame

```json
{ "type": "resize", "cols": 120, "rows": 40 }
```

**Server → Client** (terminal output): raw binary bytes

## Frontend

Uses [xterm.js](https://xtermjs.org/) with the following addons:

- `@xterm/addon-fit` — auto-resize to container dimensions
- `@xterm/addon-attach` — attach xterm directly to a WebSocket

## How It Works

1. WebSocket connection is established and JWT is validated
2. Backend opens an SSH connection using stored credentials
3. A PTY session is requested (`xterm-256color`, initial size 80×24)
4. An interactive shell is launched
5. All data flows bidirectionally: WebSocket ↔ SSH ↔ PTY

## Requirements

- SSH access to the target host (password authentication)
- The `ssh_host`, `ssh_username`, `ssh_password` settings must be configured

## License

MIT — see [LICENSE](../../LICENSE)
