How to Share Your Terminal Over the Web in Linux Using ttyd

Collaborating on Linux servers, demonstrating command-line tools to remote colleagues, or troubleshooting embedded devices often requires terminal sharing. While traditional SSH connections require configuring user accounts, generating cryptographic keys, and configuring client terminal emulators, there are scenarios where you want a colleague, student, or client to access or view a terminal session directly through their standard web browser without installing any software.

ttyd is a lightweight, high-performance command-line tool that bridges your Linux terminal to the web over WebSockets using the Xterm.js terminal engine. With ttyd, you can broadcast an interactive or read-only shell session over HTTP, complete with authentication, custom ports, and full SSL/TLS encryption.

Installing ttyd on Linux

ttyd is written in C and is available across popular Linux package managers or as a standalone static binary:

  • Ubuntu / Debian:
    sudo apt update && sudo apt install ttyd -y
  • Arch Linux:
    sudo pacman -S ttyd
  • Standalone Static Binary (Any Linux Distro):
    sudo curl -sLo /usr/local/bin/ttyd https://github.com/tsl0922/ttyd/releases/latest/download/ttyd.$(uname -m)
    sudo chmod +x /usr/local/bin/ttyd

Sharing a Basic Bash Shell via Web Browser

To start a basic terminal session accessible over your local network on the default port 7681, run:

ttyd bash

Open any web browser on your computer or local network and navigate to:

http://<your-server-ip>:7681

A responsive, full-featured terminal window running your Bash shell will appear directly inside the browser, supporting text selection, mouse clicks, and full keyboard navigation.

Protecting Your Web Terminal with Basic Authentication

Never expose an unauthenticated shell across an untrusted or public network. You can enforce a username and password using the -c (credentials) flag:

ttyd -c admin:SecretPassword123 bash

When anyone visits the web address, the browser will display an HTTP Basic Authentication dialogue requiring the specified credentials before granting access to the shell.

Sharing a Read-Only Terminal Session

If you want remote viewers to watch you compile software, run log monitors, or execute system demonstrations without allowing them to type or tamper with your session, add the -R (read-only) flag:

ttyd -R -c viewer:demo2026 htop

In this example, viewers can observe the live htop system monitor in their web browser, but keystrokes and inputs from the browser are completely blocked.

Changing the Network Port and Binding to Localhost

By default, ttyd listens on all network interfaces. You can change the port or restrict access strictly to localhost if you plan to place ttyd behind a reverse proxy (such as NGINX or Caddy):

  • Run on a custom port (e.g. 8080):
    ttyd -p 8080 bash
  • Bind strictly to localhost for NGINX reverse proxying:
    ttyd -i 127.0.0.1 -p 8080 bash

Terminating the Web Session

When you finish your demonstration or troubleshooting session, press Ctrl + C in the original terminal window where you launched ttyd. The web server will stop immediately, terminating all active browser connections cleanly.

Using ttyd transforms any Linux machine into an instant, accessible web terminal, making remote collaboration and demos completely frictionless.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.