How to Run Linux Terminal on a Web Browser Using Wetty

Run Linux Terminal on Web Browser using Wetty and invoke commands over HTTP and HTTPS. Wetty brings a flexible way to carry out command-based operations, pretty similar to how things function on the usual Linux Terminal.

Formed by the combination of two words, Web and tty, Wetty is a tool designed to help users connect to the Linux Terminal right from the web browser even without initiating a swap between the programs. With Wetty, you’ll no longer need to employ the GNOME Terminal for accessing the remote servers; rather, you can do it flexibly over web browsers.

How to Run Linux Terminal on a Web Browser using Wetty

Now that you’ve enough knowledge about Wetty, it is time I help you learn how to run Linux Terminal on a web browser using Wetty. But before anything else, you’ll need to have the repositories updated Wetty installed on your system.

Updating System Repositories

Getting your system repositories updated before installing any utility is a great practice. It ensures everything concludes with no issues whatsoever.

Launch the Terminal by using the “Ctrl+Alt+T” key combination

Run the following command:

$ sudo apt update
update repositories

Installing Wetty on Linux

Getting Wetty installed on Linux is a pretty straightforward task. Whether you own an RHEL-based or a Debian-based system, the following guide will help you make your system Wetty ready.

Step 1: Installing Git on Linux

If you’re operating on RHEL or CentOS, invoke the following command to install Git.

$ sudo yum install git 
install git

Debian or Ubuntu users, make use of the command that looks like this:

$ sudo apt install git 
install git on debian

Step 2: Installing Node.Js 14 on Linux

Remember it is crucial to install the Node.Js version 14 or greater so that you can seamlessly run Linux Terminal on a web browser using Wetty. To begin with, install all the required packages that including build-essential and Python. 

Choose and use the following command depending on the system you’re on.

RHEL/CentOS/Rocky Linux 8/Alma Linux 8 

$ sudo yum groupinstall 'Development Tools' 
Run Linux Terminal on a Web Browser Using Wetty
$ sudo yum -y install ncurses-devel make gcc g++ bc openssl-devel 
$ sudo yum -y install python3

Debian/Ubuntu

$ sudo apt install curl build-essential python3 
install python for Wetty
$ sudo apt install libncurses-dev flex libssl-dev libelf-dev bc bison

Installing Node.JS 14 

On RHEL/CentOS/Rocky Linux 

$ sudo dnf module install nodejs:14
install node.js

On Debian/Ubuntu 

$ curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - 
$ sudo apt -y install nodejs
Run Linux Terminal on a Web Browser Using Wetty

Verifying Node.JS Installation

Launch the “Terminal”

Run the following command:

$ node -v 

Step 3: Install Yarn

After installing, Node.JS 14 on your system, the next thing to do is get Yarn. Here is how:

On Debian/Ubuntu 

$ sudo apt install gnupg2 
$ curl -sL [Link] | sudo apt-key add - 
$ echo "deb [Link] | sudo tee /etc/apt/sources.list.d/yarn.list 
$ sudo apt update && sudo apt install yarn

On RHEL/CentOS/Rocky Linux/Alma Linux 

$ curl -sL [Link]| sudo tee /etc/yum.repos.d/yarn.repo 
$ sudo yum install yarn

Step 4: Installing Wetty on Linux

In this step, we’ll be using Yarn to get Wetty installed on our machine. The process is simple; just run the following command:

$ sudo yarn global add wetty

Step 5: Exporting the PATH

Soon after the installation concludes, export the PATH invoking the echo command in the following manner:

$ echo "export PATH=\$PATH:/usr/local/bin" | sudo tee -a /etc/profile source /etc/profile
expoert the PATH

Step 6: Verifying Wetty

Don’t forget to verify and ensure that Wetty is successfully installed on your system. For doing this, use the $ wetty command alongside the --help flag. 

Input:

$ wetty --help

Access and Run Linux Terminal on a Web Browser Using Wetty

To start the Wetty web interface on port 2000, you’ll need to invoke the following command:

$ wetty --host 0.0.0.0 -p 2000
access and Run Linux Terminal on a Web Browser Using Wetty

If you have the firewall enabled, allowing the desired port through it is crucial. 

Launch the “Terminal”

Run the command as:

For Firewalld Firewall

$ sudo firewall-cmd --zone=public --permanent --add-port=2000/tcp 
$ sudo firewall-cmd --reload 

For UFW Firewall

$ sudo ufw allow proto tcp from any to any port 30

Verifying the URL for Wetty

Once you’ve established an access route, it is time to verify the URL for Wetty using the echo command

$ echo https://$(curl -s4 [designated_URL]):2000

Finally, provide the workstation with your system username and password, and you’re good to go. 

Enabling Auto Login for Wetty

Enabling auto-login is a great utility for many as it allows users to get themselves logged in without inputting the username or the password again and again. However, the feature might cause infringement in the level of security. 

Step 1: Install SSH Pass

At first, you’ll need to install sshpass.

On RHEL/CentOS/Rocky Linux 8/Alma Linux 8

$ sudo yum install sshpass

On Debian/Ubuntu

$ sudo apt install sshpass

Step 2: Log in to Your Server

Use the following URL: 

http://IP_Address:2000/wetty/ssh/username?pass=password

Replace the username and password with the dedicated server login credentials, and voilà, the Wetty auto-login is enabled.

Creating Self Signed Certificate for Wetty

As the Wetty oriented connection are not secure, the login credentials travel through an unprotected path. To secure things up, what you’ll need to do is create a self-signed certificate. It will allow accessing Wetty through HTTPS, making room for more security.

Step 1: Install OpenSSL on your system

On RHEL/CentOS/Rocky Linux 8/Alma Linux 8

$ sudo yum install openssl

On Debian/Ubuntu

$ sudo apt install openssl

Step 2: Generate Self Signed Certificates

Once you’ve installed the OpenSSL on your system, you’re ready to generate a self-signed certificate and encrypt Wetty based connections.

openssl req -x509 -nodes -days 1095 -newkey ec:<(openssl ecparam -name secp384r1) -subj "/C=GB/ST=None/L=None/O=None/OU=None/CN=None" -out wetty.crt -keyout wetty.key

Step 3: Allowing Permissions

Employ mkdir, chmod, and wetty command and assign the required set of permissions to the newly created files.

$ sudo cp wetty.crt /etc/ssl/certs/wetty.crt 
$ sudo mkdir -p /etc/ssl/private/ 
$ sudo cp wetty.key /etc/ssl/private/wetty.key 
$ sudo chmod 755 /etc/ssl/certs/wetty.crt 
$ sudo chmod 755 /etc/ssl/private/wetty.key

Accessing the  Wetty Web Terminal via HTTPS

Having created self-signed certificates, you can now access Wetty via HTTPS. But before that, make sure to allow the HTTPS through the firewall, in case you’ve enabled it.

For Firewalld

$ sudo firewall-cmd --zone=public --add-service=https
$ sudo firewall-cmd --reload

For ufw

$ sudo ufw allow https

Once done, you can now access the Wetty Web Terminal and run all the desired commands just like you do on the usual Linux Terminal.

With that, I’m done guiding you on how to run Linux Terminal on a Web Browser using Wetty. From preparing your system to installing Wetty and eventually accessing the Terminal, I’ve uncovered everything in the most user-friendly manner so that you don’t find yourself troubling at any stage.

If this guide helped you, please share it.

Leave a Reply
Related Posts