How to use Wetty tool in browser - Accessing server terminal

To use Wetty tool for accessing Linux server terminal in Web browser

In this article we will learn how to access Linux server using the wetty tool. Wetty - " Web + tty" tool is used to connect the Linux server from the web browser without swapping between the programs.

To install Wetty

Utilise the following command to install the epel-repo.

[root@linuxhelp ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.webwerks.com
 * epel: mirror.rise.ph
 * extras: centos.webwerks.com
 * updates: centos.excellmedia.net
---> Package epel-release-7-7.noarch will be installed
.
.
Installed:
   epel-release-7-7.noarch is installed
Complete!

Then install the nginx web server as we are accessing Wetty tool through nginx.

[root@linuxhelp ~]# yum install nginx
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.webwerks.com
 * epel: epel.mirror.net.in
 * extras: centos.webwerks.com
 * updates: mirror.nbrc.ac.in
--> Package 1:nginx-1.6.3-9.el7.x86_64 will be installed
.
.
Installed:
    nginx-1.6.3-9.el7.x86_64
Complete!

Start the nginx services.

[root@linuxhelp ~]# systemctl start nginx
[root@linuxhelp ~]# systemctl status nginx
 nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service  disabled)
   Active: active (running) since Fri 2016-07-22 12:05:59 IST  2min 25s ago
  Process: 3577 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 3574 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 3573 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 3580 (nginx)
   CGroup: /system.slice/nginx.service
           +-3580 nginx: master process /usr/sbin/nginx
           +-3581 nginx: worker process

Next install the git package, to clone the wetty tool.

[root@linuxhelp ~]# yum install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.fibergrid.in
* epel: mirror.rise.ph
* extras: mirror.fibergrid.in
* updates: mirror.fibergrid.in
--> Package git-1.8.3.1-6.el7_2.1.x86_64 will be installed
.
.
Installed:
git-1.8.3.1-6.el7_2.1.x86_64
Complete!

Before cloning, install the required additional packages.

To install gcc, gcc-c++, openssl-devel

[root@linuxhelp ~]# yum install gcc gcc-c++ openssl-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: mirror.premi.st
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Package gcc-4.8.5-4.el7.x86_64 will be installed
Package gcc-c++-4.8.5-4.el7.x86_64 will be installed
Package 1:openssl-devel-1.0.1e-51.el7_2.5.x86_64 will be installed
.
.
.
Installed:
    gcc-4.8.5-4.el7.x86_64
    gcc-c++-4.8.5-4.el7.x86_64
    openssl-devel-1.0.1e-51.el7_2.5.x86_64
Complete!

To install node.js

Download the tar package from its official site
https://nodejs.org/en/download/

and then install it.

Extract the downloaded tar file by using the following command.

[root@linuxhelp Downloads]# mv node-v4.4.7.tar.gz /usr/local/src/
[root@linuxhelp src]# tar xvzf node-v4.4.7.tar.gz

Install the nodejs package into the newly created directory as follows.

[root@linuxhelp ~]# cd node-v4.4.7
[root@linuxhelp ~]# ./configure
[root@linuxhelp ~]# make
[root@linuxhelp ~]# make install

To install npm package

Install the npm package and also install nodejs by utilising the following command.

[root@linuxhelp ~]# yum install npm nodejs
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.webwerks.com
 * epel: mirror.rise.ph
 * extras: centos.webwerks.com
 * updates: mirror.nbrc.ac.in
Package npm-1.3.6-5.el7.noarch will be installed
Package nodejs-0.10.42-4.el7.x86_64 will be installed
.
.
.
Installed:
    npm-1.3.6-5.el7.noarch
    nodejs-0.10.42-4.el7.x86_64
Complete!

Clone the wetty tool with github by running the following command.

[root@linuxhelp ~]# git clone https://github.com/krishnasrinivas/wetty
Cloning into ' wetty' ...
remote: Counting objects: 206, done.
remote: Total 206 (delta 0), reused 0 (delta 0), pack-reused 206
Receiving objects: 100% (206/206), 378.98 KiB | 182.00 KiB/s, done.
Resolving deltas: 100% (98/98), done.

Run the clone command in root' s home directory.

After cloning, a new directory called ' wetty' will be created. Now install npm inside the wetty directory.

[root@linuxhelp ~]# cd wetty
[root@linuxhelp wetty]# npm install

To Start the Wetty tool to access the Linux terminal via browser, run the following command.

[root@linuxhelp ~]# node app.js -p 8080
http on port 8080

Open the browser and visit http://< IP_address> :8080
Login with the user credentials and start using from terminal.

If the connection is terminated, see the logs in terminal.

For a secured connection, start wetty with https by generating the certificate.

[root@linuxhelp ~]# openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

To launch Wetty via HTTPS, execute the following command.

[root@linuxhelp ~]# nohup node app.js --sslkey key.pem --sslcert cert.pem -p 8080 & 

Wetty is started in the background listening on port 8080.

FAQ
Q
What is the Purpose of using the wetty tool?
A
Wetty - "Web + tty" tool is used to connect the Linux server from the web browser without swapping between the programs.
Q
How to start wetty with https by generating the certificate?
A
Execute the following command as
"openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes"
Q
What are the Alternative for Wetty tool?
A
Gate One,
Shell in A Box,
TinyShell,
KeyBox,
Onion Terminal
Q
How can I connect the Linux server from the web browser on the Public network?
A
Yes. If you have to know the authentication for accessing the Linux server
Q
How to clone the Wetty GitHub Repository?
A
By using this command you can clone
# cd /root
# git clone https://github.com/krishnasrinivas/wetty