mh0m@research:~$

Ternimal 1.0: a minimal, secure remote terminal with MCP

5 min read
+------------------------------------------------------------------+
| \\\_\                                                            |
| \\\( ^>     t e r n                                              |
|  \\\=/      A minimal, portable, secure remote terminal with MCP |
|  ~~~~~      v1.0.0                                               |
+------------------------------------------------------------------+

Today I'm releasing Ternimal 1.0. The name is terminal plus minimal. It is a remote terminal that stays small, runs on every platform Go targets, and keeps every byte between you and the host encrypted. That holds even when the host sits behind NAT and the traffic goes through a relay.

It ships as four self-contained binaries:

binary role
tern the client: shells, exec, port forwards, file copy, a REST gateway and an MCP server
ternd the agent: hosts sessions for authenticated clients, listening directly or dialing out to a relay
ternr the relay: a public meeting point that only forwards opaque bytes
rtern relay and client in one process, for when one person needs one box

Up in a minute

Run ternd with no flags. It mints a token and prints its certificate fingerprint and a ready-to-paste connect line:

# on the host
ternd

# from your machine
TERN_TOKEN=<token> tern connect -a AGENT_IP:2222 -f <agent-fp>

tern connecting directly to ternd

The client pins the agent's certificate, and authentication is mandatory. You can use a token, or OpenSSH keys in authorized_keys format. There is no unauthenticated mode to forget to turn off.

One connection carries the shell, exec, local and remote port forwards and file copy at once. Sessions have names and outlive the connection. You can drop off, reconnect and pick up where you were, or share a session with read-only viewers.

Behind NAT

When the host cannot take inbound connections, the agent dials out to a relay instead:

# relay, on a public host
export TERN_RELAY_TOKEN="$(tern genkey)"
ternr --addr 0.0.0.0:7000

# agent, behind NAT
TERN_RELAY_TOKEN=<relay-token> ternd --relay RELAY:7000 \
  --relay-fingerprint <relay-fp> --id box1

# client: paste the tern1: line the agent printed
TERN_RELAY_TOKEN=<relay-token> TERN_TOKEN=<token> \
  tern connect --to tern1:...

The relay is only a byte pipe. TLS and authentication run end to end between client and agent, so the relay never sees the session in plaintext and cannot pose as the agent. The relay token is proved to the relay, never sent to it. For one person reaching one box, rtern is the relay and the client in a single process: it waits, the agent dials in, and you land in its shell.

Handing a terminal to an AI agent

The headline of 1.0 is tern mcp. It is a Model Context Protocol server that lets an AI client work on your hosts. Claude Code, Claude Desktop, Cursor and VS Code all work with it. It starts from the idea that a model should get only what the job needs.

With no config file it serves one host under a built-in read-only profile. That profile is a short allowlist of inspection commands, plus reads of configuration and logs. The quickest way in is the Claude Code plugin. It runs tern mcp with a config file and adds skills that walk you through the setup:

claude plugin marketplace add ternimal/tern
claude plugin install ternimal@ternimal

A config file gives each host a profile. A profile can add allowed commands, shell mode, file reads and writes within path patterns, background jobs and interactive terminals, each within limits. The safety model in five lines:

  • Every call is checked against the host's profile on your machine before anything reaches the agent, and every call goes into an audit log.
  • Actions you list under confirm are shown to you first, escaped and never cut short. Each approval is bound to that exact action and works once.
  • Credential stores, private keys, shell histories and the settings of MCP clients and AI coding tools are never readable or writable, whatever a profile says.
  • Known secret formats are redacted from what the model reads.
  • The model cannot pick which session its terminal opens in. The tern connect --read-only line that pty_open returns lets you watch the AI's terminal live, and you can take it over.

an MCP client driving tern mcp while a person watches the same terminal

The client on the left of the recording is a scripted MCP client that makes the calls an AI agent makes. tern mcp, ternd and tern connect are the real binaries.

To be clear about scope: tern mcp protects you from a model doing things you did not intend. It enforces its policy on your machine, with your credentials. It is not a boundary against someone who already controls your machine or your MCP client, so keep the agent's own privileges as low as the work allows.

Releases you can check

Every release asset comes with a SHA-256 sum and a build provenance attestation, and a release cannot be changed once it is published:

base=https://github.com/ternimal/tern/releases/latest/download
curl -LO "$base/ternimal-linux-amd64.zip"
curl -LO "$base/SHA256SUMS"
sha256sum --ignore-missing -c SHA256SUMS
gh attestation verify ternimal-linux-amd64.zip -R ternimal/tern

The builds are reproducible. Run make release VERSION=v1.0.0 with go1.26.10 in a clean clone of the tag, and every zip comes out with the same bytes as the published one. android/amd64 is the one cgo build, so it also needs the same Android NDK. If you would rather build from source:

go install github.com/ternimal/tern/cmd/...@latest

There are builds for Linux, macOS, Windows and Android on amd64 and arm64. To host a shell, Windows needs Windows 10 1809 or Windows Server 2019 or later, for ConPTY.

Use it on your own systems

Ternimal is an administration tool, not a stealth tool. Connections are logged and there is no unauthenticated mode. The insecure flags exist only for testing, and each one prints a loud warning. Use it on systems you own or are authorized to access.

If you find a security issue, please report it privately through the repository's private vulnerability reporting, as SECURITY.md describes.

Ternimal is AGPL-3.0-only. The code, docs and releases are at github.com/ternimal/tern.

← back to posts