How to Access Linux Server Terminal in Web Browser Using ‘Wetty (Web + tty)’ Tool

As a system administrator, you probably connect to remote servers using a program such as GNOME Terminal (or the like) if you’re on a Linux desktop, or an SSH client such as Putty if you have a Windows machine, while you perform other tasks like browsing the web or checking your email.

[ You might also like: Cockpit – A Browser-Based Administration Tool for Linux ]

Wouldn’t it be fantastic if there was a way to access a remote Linux server directly from the web browser? Luckily for us all, there is a tool called Wetty (Web + tty) that allows us to do just that – without the need to switch programs and all from the same web browser window.

Installing Wetty in Linux

Wetty is available from the GitHub repository of its developer. For that reason, regardless of the distribution, you’re using some dependencies that must be installed first manually before cloning the repository locally and installing the program.

In RHEL-based distros, such as CentOS, Rocky Linux, and AlmaLinux, you need to install NodeJS and the EPEL repository as shown:

# yum groupinstall 'Development Tools'
# curl -fsSL https://rpm.nodesource.com/setup_17.x | bash -
# yum update 
# yum install epel-release git nodejs npm

In Debian and its derivatives, the version of NodeJS available from the distribution’s repositories is older than the minimum version required to install Wetty, so you have to install it from the NodeJS GitHub developer repository:

# apt install curl build-essential
# curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
# apt update && apt install -y git nodejs npm

After installing these dependencies, clone the GitHub repository:

# git clone https://github.com/krishnasrinivas/wetty
Wetty Terminal Access Web
Clone Wetty – A Terminal Access Web

Change the working directory to wetty, as indicated in the message above:

# cd wetty

then install Wetty by running:

# npm install

If you get any error messages during the installation process, please address them before proceeding further. In my case, the need for a newer version of NodeJS in Debian was an issue that had to be solved before running npm install successfully.

Starting Wetty and Access Linux Terminal from Web Browser

At this point, you could start the web interface in local port 8080 for Wetty by running (this assumes your current working directory is /wetty):

# node app.js -p 8080

As you can see in the image below:

Access Wetty Linux Terminal from Web
Access Wetty Linux Terminal from Web

But do yourself a favor and DO NOT enter your username and password since this connection is not secure and you don’t want your credentials to travel through the wire unprotected.

For that reason, you should always run Wetty through HTTPS. Let’s create a self-signed certificate to secure our connection to the remote server:

# openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

And then use it to launch Wetty via HTTPS.

Please note that you will need to open the custom HTTPS port where you will want to run Wetty:

# firewall-cmd --add-service=https # Run Wetty in the standard HTTPS port (443)
# firewall-cmd --permanent --add-service=https
# firewall-cmd --add-port=XXXX/tcp # Run Wetty on TCP port XXXX
# nohup node app.js --sslkey key.pem --sslcert cert.pem -p 8080 &

The last command in the above sequence will start Wetty in the background listening on port 8080. Since we are using a self-signed certificate, it is to be expected that the browser will show a security warning – It is perfectly safe to ignore it and add a security exception – either permanently or for the current session:

Wetty - SSL Security Warning
Wetty – SSL Security Warning

After you have confirmed the security exception you will be able to login to your VPS using Wetty. It goes without saying that you can run all commands and programs as if you were sitting in front of a real or virtual terminal, as you can see in the following screen cast:

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Gabriel Cánepa
Gabriel Cánepa is a GNU/Linux sysadmin and web developer from Villa Mercedes, San Luis, Argentina. He works for a worldwide leading consumer product company and takes great pleasure in using FOSS tools to increase productivity in all areas of his daily work.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

13 Comments

Leave a Reply
  1. Having issues getting this working on a Linux Mint distro (17.3)

    I install dependencies, type “node app.js -p 8080” but I get this:
    —————————————————————————————————-

    module.js:338
    throw err;
    ^
    Error: Cannot find module ‘bytes’
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object. (/home/alan/wetty/node_modules/express/node_modules/connect/lib/utils.js:394:22)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

    —————————————————————————————————————————————-
    Not sure where to go from there. I’m an amateur when it comes to Linux, so I don’t know how to resolve this.

    Reply
    • @Alan,
      If you followed the installation instructions at the top of this post, you must have installed npm. You can verify this by running
      dpkg -l | grep npm
      or
      which npm
      If npm is installed (as it should), the first command should return the actual package name, whereas the output of the second command will show the path to the executable file. Otherwise, install npm first following the instructions given here.
      Next, install the bytes module:
      sudo npm install bytes
      Then try again and let us know how it went.

      Reply
      • OK, after I enter “node app.js -p 8080” I’m getting this:

        ————————————————————————————————————–
        module.js:338
        throw err;
        ^
        Error: Cannot find module ‘serve-static’
        at Function.Module._resolveFilename (module.js:336:15)
        at Function.Module._load (module.js:278:25)
        at Module.require (module.js:365:17)
        at require (module.js:384:17)
        at Object. (/home/alan/wetty/node_modules/express/node_modules/connect/lib/middleware/static.js:19:18)
        at Module._compile (module.js:460:26)
        at Object.Module._extensions..js (module.js:478:10)
        at Module.load (module.js:355:32)
        at Function.Module._load (module.js:310:12)
        at Module.require (module.js:365:17)
        _________________________________________________________________

        Seems like I’m closing in on it, the errors are getting shorter.

        Sorry to be a pain, I do appreciate the help.

        Reply
        • @Alan,

          I am not familiar with Wetty, but still I think the server-static module is missing and you need to install through npm as shown:

          # npm install serve-static
          

          Let me know after you installing the above module, are you able to execute node app.js -p 8080 command?

          Reply
          • There was another NPM module that it complained about missing too. Did some Googling and found the NPM website, and looked at the services it needed. Did NPM installs on those items, then it worked.

            Between the help here, and doing some brainstorming, I’m figuring out how to make things work.

            Now, if I could just figure out how to have Wetty start on a reboot, I’d be good. Right now, I have to login to the machine, start the service, and then I can access it with a web browser. The terminal I opened to add the command has to stay open, though, which kind of defeats the purpose.

            I don’t really need a secure connection for it; the port isn’t available to the outside, so I just want to have it start on regular HTTP, not HTTPS.

            Wanted to be able to access it from inside my home network with my cellphone, but for some reason, it doesn’t pop up the keyboard on my phone after I connect(I see the login prompt, but my phone’s browser doesn’t recognize that it needs keyboard input). I haven’t tried my Android tablet, but I suspect it will have the same result.. Not sure how to resolve that, but I’ll try to figure it out.

            Of course, if I could find a terminal application for my Android phone that actually allows me to SSH into Linux boxes on my home network, that might even eliminate the need for Wetty for anything other than the Windows box.

            Thank you again to everyone that has helped. I am an amateur at this, and it’s a learning curve, but I’m enjoying learning Linux.

        • @Alan,
          I am replying to this comment because I didn’t find the Reply link on the one below. If you’re still looking for an application that allows you to SSH into your Linux servers using your Android phone, I’d highly recommend JuiceSSH (https://juicessh.com/). I’ve used it in a production environment and gets the job done pretty well. Hope it helps.

          Reply
  2. Trying to identify whether there is an option to leverage certificates with Wetty so that the connection will be based on public / private key pairs.

    Reply
    • @Ivaylo,
      As Wetty works over a web connection, I would say it’s best to go with the certificates (you may want to consider using one signed from a CA if you don’t want your users to run into the “This connection is not trusted” message). Otherwise, feel free to check the GitHub repository for further ideas on how to use Wetty. You may even suggest this option be included in future releases of the program.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.