Ever wish you could quickly share your terminal session with someone without multiple layers of hassle? With ttyd, you can. This little utility turns your terminal into a live, interactive web app. No screen sharing. No tricky setups. Just your terminal, on the web, ready to go.
What Is ttyd and How Does It Work
ttyd is a lightweight command-line tool that lets you share your terminal over the web with just a single command. You don’t require any complicated setup or any other third-party services. It’s a simple way to turn your local terminal into a web-accessible one.
At its core, ttyd wraps any command you want (such as a shell like bash or zsh) and serves it through a secure, browser-based interface. You start it up, and it launches a web server that anyone connected to your network can access to interact with your terminal in real time, directly from their browser. Think of it like screen sharing for your terminal, only more interactive and accessible.
Whatever activities others do on the shared terminal happen in real-time on your system and stay there permanently. For example, you share a terminal session. Someone enters that session and creates a new file. That file is actually created on your system and stays there. So, everything is in sync.
Especially if you open your ttyd server up to the wider web, it’s handy for remote support, quick demos, collaborative troubleshooting, or even managing a headless device from afar. It’s also fast and responsive due to being created with libuv and WebGL2.
This also means that if your session falls into the hands of the wrong person, things can get troublesome. However, ttyd comes with several security mechanisms, which I’ll show you later.
Installing ttyd on Linux
You can install ttyd in multiple ways on Linux. The developers recommend downloading the installation binary from the official GitHub page for installation. Go to the releases page. Choose the binary version that’s suitable for your system.
I will go with the x86_64 version since that’s what my system supports. You can also use the wget command to download the file.
wget https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64
Note that your command may change slightly depending on the latest version of the binary as well as the architecture. Once downloaded, provide executable permission to the file via chmod.
chmod +x ttyd.x86_64
If you have Homebrew set up, you can use that to install ttyd.
brew install ttyd
If you have Snap enabled on your system, you can use that too.
sudo snap install ttyd —classic
If you want to build the app from source, that’s also possible. First, update your system.
sudo apt-get update
Install the necessary dependencies and tools with this command:
sudo apt-get install -y build-essential cmake git libjson-c-dev libwebsockets-dev
Clone the GitHub repository, navigate into the «ttyd» directory, create a «build» directory, and navigate into it.
git clone https://github.com/tsl0922/ttyd.git
cd ttyd && mkdir build && cd build
Finally, build the app.
cmake ..
make && sudo make install
For demonstration, I’ll be using the app from the GitHub release page.
Using ttyd to Share Your Terminal on the Web
The basic syntax of ttyd is like this:
ttyd [options] [command] [arguments…]
For a simple use, pass any Linux command to ttyd.
ttyd bash
This created a web server session on http://localhost:7681. Visit the URL on your web browser to see it.
The default port is 7681. If you want to change the port, you can do that by adding the -p option.
ttyd -p 7777 bash
This time, you’ll need to visit http://localhost:7777 to find the session. You can also view various terminal tools. Let’s try Vim.
ttyd vim
Even the top tool or any other system monitoring software.
ttyd top
Exploring Advanced Options
There are many options in ttyd that make your session more interactive and fruitful. The default sessions I created earlier were read-only. That means you can’t write anything in the terminal from the browser. To make it writable, you need to pass the -W or —writable option.
ttyd -W nano
You can add your device’s login system to your share.
ttyd -W login
If you face any root permission errors, precede it with the sudo command.
sudo ttyd -W login
You also need the -W option for typing your username and password.
If you want to add some security to your session, you can add username and password authentication using the -c option.
ttyd -c user:password bash
With this, any user trying to join the session will be required to input a username and a password. There are other security options available as well, such as adding SSL encryption.
There are many more things to try out in ttyd. If you’re stuck or want to explore more, try using the -h flag to display the help mode to check the available options. You can also check the official GitHub for more information. Many great Linux tools allow you to share your Android screen or even record quick terminal sessions.