Operations 9 min read

Turn Your Local Shell into a Web Terminal with ttyd – Quick Setup Guide

This tutorial shows how to install and use ttyd, a C‑based tool that shares a local terminal over the web via WebSocket, covering basic commands, port binding, authentication, Docker deployment, SSH support, SSL configuration, and public exposure with ngrok.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Turn Your Local Shell into a Web Terminal with ttyd – Quick Setup Guide

Web Terminal Options

ttyd – C implementation that streams a terminal to the browser.

gotty – Go implementation, last updated in 2017.

wetty – Node.js based, requires SSH login.

Chrome Secure Shell – browser extension providing a web‑based SSH terminal.

tmate – tmux‑derived tool for sharing terminals.

Installation

On macOS install via Homebrew: brew install ttyd For Windows or Linux, follow the installation guide at https://github.com/tsl0922/ttyd#installation.

Basic Usage

Start a web‑based Bash shell: ttyd bash The terminal is reachable at http://localhost:7681/ (default port 7681).

ttyd bash screenshot
ttyd bash screenshot

Changing Shell

Replace bash with any installed shell, e.g., Zsh:

ttyd zsh
ttyd zsh screenshot
ttyd zsh screenshot

Port Binding

Change the listening port with -p: ttyd -p 8000 zsh Access the terminal at http://localhost:8000/.

Basic Authentication

Secure the terminal using Basic Auth. Provide credentials with -c in the format username:password: ttyd -p 8000 -c admin:admin zsh Clients must log in before using the terminal.

Basic Auth login
Basic Auth login

Auto‑Open Browser

Launch the default browser automatically with -B: ttyd -p 8000 -B zsh Example alias for quick start: alias webcmd="ttyd -p 8000 -B zsh" Running webcmd opens the terminal in the browser.

Docker Support

Run ttyd from the official Docker image: docker run -it --rm -p 7681:7681 tsl0922/ttyd Mount host directories if you need to expose the host filesystem.

SSH Terminal

Enable SSH login before accessing the terminal: ttyd login Clients must provide valid SSH credentials.

SSL Support

Configure HTTPS by generating a certificate and using the SSL options:

ttyd -S -C /path/to/cert.pem -K /path/to/key.pem [other options] <command>

See the SSL usage guide at https://github.com/tsl0922/ttyd/wiki/SSL-Usage for details.

Public Exposure with ngrok

Expose the web terminal to the internet using ngrok: ngrok http 8000 ngrok provides a public URL such as https://example.ngrok.io/ that anyone can use to access the terminal.

ngrok tunnel
ngrok tunnel

Conclusion

ttyd offers a lightweight way to share a machine’s terminal over the web. It supports custom shells, port configuration, Basic Authentication, automatic browser launch, Docker deployment, SSH login, SSL encryption, and public exposure via tools like ngrok.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerWebSocketcommand-linengrokttyd
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.