We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Run Linux Terminal on Web Browser using Wetty

Learn how to – How To Run Linux Terminal on Web Browser using Wetty.

System administrators in their daily tasks need to connect to remote servers using applications such as the GNOME Terminal on Linux or using an SSH client like Putty for Windows Systems.

There is another fantastic way that allows one to access the terminal directly from the web over HTTP and HTTPS. This tool is called Wetty, originates from the two words web+tty. With Wetty, you can carry out all the operations you do on your terminal. It uses hterm terminal emulator as a backend with WebSockets instead of JavaScript.

Wetty has the following amazing features:

  • It is embeddable, can be integrated into other web-based applications.
  • Has resuming sessions
  • Auditability as the communication between the SSH server and the client must pass through the web application
  • Tunnels the communication through a web application server thus restricting anonymous access.
  • Easily accessed as it requires no local software installation on the client system.

Setup pre-requisites:

In this guide, I will illustrate how you can run Linux Terminal on Web Browser using Wetty(web+tty). For this setup to run, you will require the following installed on your system.

  • python
  • make
  • nodejs version 14 and above.
  • build-essential
  • Git

Step 1 – Install Wetty on Linux

In this guide, I will demonstrate how to install Wetty on both RHEL-based and Debian-based systems:

First, install the required dependencies as below.

1. Install Git on Linux

Since we will be cloning Wetty from the GitHub repo, we need to have git installed.

##On RHEL/CentOS/Rocky Linux 8/Alma Linux 8
sudo yum install git 

##On Debian/Ubuntu
sudo apt update
sudo apt install git 

2. Install Node.JS 14 on Linux

Since we require a NodeJs version greater than 14, we will install Node.Js 14 on our Linux system as below.

First install the required packages, i.e build-essential and Python as below

##On RHEL/CentOS/Rocky Linux 8/Alma Linux 8
sudo yum groupinstall 'Development Tools'
sudo yum -y install ncurses-devel make gcc g++ bc openssl-devel
sudo yum -y install python3

##On Debian/Ubuntu
sudo apt install curl build-essential python3 
sudo apt install libncurses-dev flex libssl-dev libelf-dev bc bison

Then install Node.js 14 locally as below.

##On Debian/Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt -y install nodejs

##On RHEL/CentOS/Rocky Linux
sudo dnf module install nodejs:14

Verify the installed node version.

$ node -v

Install Yarn.

##On Debian/Ubuntu
sudo apt install gnupg2
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | 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 https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

3. Install WeTTY on Linux

Now we will use Yarn to install WeTTY on our system

sudo yarn global add wetty

Sample Output:

warning wetty > socket.io > socket.io-parser > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
warning wetty > socket.io > engine.io > debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "wetty@2.1.1" with binaries:
      - wetty
Done in 33.83s.

With the installation complete. Export the PATH as below.

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

Verify the Wetty installation as below.

$ wetty --help
  --help, -h      Print help message                                   [boolean]
  --version       Show version number                                  [boolean]
  --conf          config file to load config from                       [string]
  --ssl-key       path to SSL key                                       [string]
  --ssl-cert      path to SSL certificate                               [string]
  --ssh-host      ssh server host                                       [string]
  --ssh-port      ssh server port                                       [number]
  --ssh-user      ssh user                                              [string]
  --title         window title                                          [string]
  --ssh-auth      defaults to "password", you can use "publickey,password"
                  instead                                               [string]
  --ssh-pass      ssh password                                          [string]

Step 2 – Access Linux Terminal from Web Browser using Wetty(web+tty)

If you have firewalld enabled, allow the port 3000 through the firewall as below.

### Firewalld Firewall ###
sudo firewall-cmd --zone=public --permanent --add-port=3000/tcp
sudo firewall-cmd --reload

### UFW Firewall ###
sudo ufw allow proto tcp from any to any port 3000

Start Wetty web interface on port 3000 with the command

$ wetty --host -p 3000

Verify the URL for Wetty with the command:

echo https://$(curl -s4 icanhazip.com):3000

At this point, you can access the WeTTY web UI via the URL http://IP_address:3000/wetty

Provide your system username and password as below.

Since the connection is not secure and you do not want your login credentials to travel through the unprotected wire, you might need to access Wetty through HTTPS. We need to create a self-signed certificate that allows us to access Wetty through HTTPS.

Step 3 – Enable WeTTY Auto Login.

The auto-login feature enables one to log in without using the username or password. This feature however is not recommended for security reasons. To enable this feature first install sshpass.

##On RHEL/CentOS/Rocky Linux 8/Alma Linux 8
sudo yum install sshpass

##On Debian/Ubuntu
sudo apt install sshpass

Now proceed as login to your server using the URL: http://IP_Address:3000/wetty/ssh/username?pass=password

In the URL replace the username and password with the server login credentials. You should be logged in without a password.

Step 4 – Create a Self-Signed Certificate for Wetty

For you to be able to create self-signed certificates, you need OpenSSL installed on your system.

##On RHEL/CentOS/Rocky Linux 8/Alma Linux 8
sudo yum install openssl

##On Debian/Ubuntu
sudo apt install openssl

Now generate the self-signed certificates to encrypt our Wetty web traffic as below

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

Assign required permissions to the files created

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

Step 5 – Create Wetty Systemd service.

For us to be able to manage the WeTTY service, i.e start, enable and stop the service when required, we need to create the wetty.service file.

Using your favorite editor, create the file as below.

sudo vim /etc/systemd/system/wetty.service

In the file, add the below contents:


ExecStart=/bin/bash -c "wetty --host -p 3000 --title wetty --ssl-key /etc/ssl/private/wetty.key --ssl-cert /etc/ssl/certs/wetty.crt"


Now reload daemons as below.

sudo systemctl daemon-reload

Start and enable WeTTY with the command.

sudo systemctl enable wetty
sudo systemctl start wetty

Check the status of the service.

$ systemctl status wetty
 wetty.service - WeTTY
   Loaded: loaded (/etc/systemd/system/wetty.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-12-23 11:16:00 EST; 18s ago
 Main PID: 86999 (node)
    Tasks: 13 (limit: 36438)
   Memory: 31.9M
   CGroup: /system.slice/wetty.service
           ├─86999 node /usr/local/bin/wetty --host -p 3000 --title wetty --ssl-key /etc/ssl/private/wetty.key --ssl-cert /etc/ssl/certs/wett>
           └─87010 login -h localhost

Dec 23 11:16:00 localhost.localdomain systemd[1]: Started WeTTY.
Dec 23 11:16:01 localhost.localdomain wetty[86999]: {"base":"/wetty/","label":"Wetty","level":"info","message":"Starting server","port":3000,"ssl":{">
Dec 23 11:16:01 localhost.localdomain wetty[86999]: {"connection":"https","label":"Wetty","level":"info","message":"Server started","port":3000,"time>
Dec 23 11:16:05 localhost.localdomain wetty[86999]: {"label":"Wetty","level":"info","message":"Connection accepted.","timestamp":"2021-12-23T16:16:05>
Dec 23 11:16:05 localhost.localdomain wetty[86999]: {"address":"localhost","label":"Wetty","level":"info","message":"Process Started on behalf of us

If you need to restart the WeTTY service use the command:

sudo systemctl restart wetty

Step 6 – Access Wetty Web Terminal via HTTPS

Now, you can access the Wetty via HTTPS using the certificates generated. The URL to access the web interface is https://IP_Address:3000 or https://hostname:3000.

If you have a firewall enabled on your system, allow the HTTPS through it with the command.

##For ufw
sudo ufw allow https

##For Firewalld
sudo firewall-cmd --zone=public --add-service=https
sudo firewall-cmd --reload

Now you should be able to access your Wetty Web Terminal via HTTPS as below.

From the Wetty Web terminal, you can run all the commands similar to those you issue on the Normal Terminal.

Step 7 – File Downloading with WeTTY.

WeTTY also supports file downloading. To configure this, you need to add the below lines to .bashrc

$ sudo vim .bashrc
function wetty-download() {
  printf "33[5i"$(cat /dev/stdin | base64 -w 0)"33[4i"

Source the profile.

source .bashrc

Now you are set to download files using WeTTY. For example, to download a file example.txt I will proceed as below.

cat example.txt | wetty-download

Wetty will then issue a pop-up with the link to a local file blob will be displayed as below.


This is the end! We have successfully gone through how to run Linux Terminal on Web Browser using WeTTY. I hope this guide was significant to you.

See more on this page:


Your Cart is Empty

Back To Shop