Raspberry Pi

Share your Raspberry Pi Terminal on the Browser Using ttyd

Want to share your Raspberry Pi terminal over the browser? Install ttyd. It’s an open-source program that enables users to access the Linux terminal on the browser. Thus, it can open the opportunity for other users to access the terminal from a remote location using the system IP address.

Follow this tutorial to learn how to set up and use ttyd to make your Raspberry Pi accessible from your browser.

Share your Raspberry Pi Terminal on the Browser Using ttyd

To install and utilize ttyd on your Raspberry Pi system, follow the step-by-step instructions provided below:

Step 1: Before installing ttyd on Raspberry Pi, ensure the required packages on the system are updated.

sudo apt update

Step 2: Then install a few dependencies on Raspberry Pi from the following command:

sudo apt-get install build-essential cmake git libjson-c-dev libwebsockets-dev

Step 3: Now use the following command to copy the ttyd source files from the GitHub website save it on Raspberry Pi system:

git clone https://github.com/tsl0922/ttyd.git

Step 4: After downloading, use the command below to access to the ttyd source directory:

cd ttyd

Step 5: Then create a build directory inside the ttyd source directory and navigate to it from the following command:

mkdir build && cd build

Step 6: Inside the build directory, run the cmake command to build packages required for installing ttyd on Raspberry Pi.

cmake ..

Step 7: Now, to perform the ttyd installation on Raspberry Pi, run the make and make install command on the system.

sudo make && sudo make install

Step 8: Run the command to verify that ttyd is successfully installed on the system.

ttyd --version

Step 9: Once the installation is completed, you can run the ttyd daemon on the terminal from the following command:

ttyd -p 8080 bash

Note: If you run the above command with sudo, you will get the root privileges access on the browser.

Step 10: After the execution of the above command, you can access your Raspberry Pi terminal from any web browser by navigating to the IP address of your Raspberry Pi (find through hostname -I command) and the port number you specified earlier.

Every command you desire may now be executed directly from your browser.

Conclusion

For remote access to your Raspberry Pi terminal, ttyd is a fantastic utility. First, you have to download the source file using the “git” command. Then inside the ttyd source directory, run create a build directory and build packages through the “cmake ..” command. After that run the “make” and “make install” command to complete the ttyd installation. Then to access the terminal on the web, run the ttyd daemon on the terminal and use the Raspberry Pi IP address to open the terminal on any browser.

About the author

Hiba Shafqat

I am a Computer Science student and a committed technical writer by choice. It is a great pleasure to share my knowledge with the world in which I have academic expertise.