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.
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).
Changing Shell
Replace bash with any installed shell, e.g., Zsh:
ttyd zshPort 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.
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.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
