Shell In A Box – A Web-Based SSH Terminal to Access Linux via Browser

Shell In A Box (pronounced as shellinabox) is a web-based terminal emulator created by Markus Gutschke. It has a built-in web server that runs as a web-based SSH client on a specified port and prompts you to a web terminal emulator to access and control your Linux Server SSH Shell remotely using any AJAX/JavaScript and CSS-enabled browsers without the need for any additional browser plugins such as FireSSH.

In this tutorial, I describe how to install Shellinabox and access a remote SSH terminal using a modern web browser on any machine. Web-based SSH access to Linux servers is very useful when you are protected with a firewall and only HTTPS traffic can get through.

Installing Shellinabox on Linux Systems

By default, the Shellinabox tool is included on Debian-based Linux distributions through default repositories using the default package manager as shown.

Install Shellinabox on Debian, Ubuntu & Mint

$ sudo apt install openssl shellinabox
Install Shellinabox in Ubuntu
Install Shellinabox in Ubuntu

Install Shellinabox on RHEL, Fedora, Rocky & AlamLinux

On Red Hat-based distributions, you need to install it from the source using the following commands.

# yum install git openssl-devel pam-devel zlib-devel autoconf automake libtool
# git clone https://github.com/shellinabox/shellinabox.git && cd shellinabox
# autoreconf -i
# ./configure && make

Configuring Shellinabox in Linux Systems

By default, shellinaboxd listens on TCP port 4200 on localhost. For security reasons, I change this default port to a random (i.e. 6175) to make it difficult for anyone to reach your SSH box.

Also, during installation, a new self-signed SSL certificate is automatically created under “/var/lib/shellinabox” to use HTTPS protocol.

$ sudo vi /etc/default/shellinabox
OR 
$ sudo nano /etc/default/shellinabox

Make the configuration changes as shown below…

# Should shellinaboxd start automatically
SHELLINABOX_DAEMON_START=1

# TCP port that shellinboxd's webserver listens on
SHELLINABOX_PORT=6175

# Parameters that are managed by the system and usually should not need
# changing:
# SHELLINABOX_DATADIR=/var/lib/shellinabox
# SHELLINABOX_USER=shellinabox
# SHELLINABOX_GROUP=shellinabox

# Any optional arguments (e.g. extra service definitions).  Make sure
# that that argument is quoted.
#
#   Beeps are disabled because of reports of the VLC plugin crashing
#   Firefox on Linux/x86_64.
SHELLINABOX_ARGS="--no-beep"

# specify the IP address of an SSH server
OPTS="-s /:SSH:192.168.0.140"

# if you want to restrict access to shellinaboxd from localhost only
OPTS="-s /:SSH:192.168.0.140 --localhost-only"

Once you’ve done with the configuration, you can restart and verify the shellinabox service by issuing the following commands.

$ sudo systemctl restart shellinabox
$ sudo systemctl status shellinabox
Start Shellinabox in Linux
Start Shellinabox in Linux

Now let’s verify whether Shellinabox is running on port 6175 using the netstat command.

$ sudo netstat -nap | grep shellinabox
Check Shellinabox Port
Check Shellinabox Port

Make sure you secure your shellinabox on the firewall and open the 6175 port for a specific IP Address to access your Linux shell remotely.

------- On Debian, Ubuntu and Mint -------
$ sudo ufw allow 6175/tcp
$ sudo ufw allow from 192.168.0.103 to any port 6175   

------- On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux -------
$ sudo firewall-cmd --zone=public --add-port=6175/tcp  
$ sudo firewall-cmd --zone=public --add-source=192.168.0.103/6175 --permanent

Access Linux SSH Terminal via Web Browsers

Now open up your web browser, and navigate to https://Your-IP-Adress:6175. You should be able to see a web-based SSH terminal. Log in using your username and password and you should be presented with your shell prompt.

Access Linux SSH Terminal in Web Browser
Access Linux SSH Terminal in Web Browser
Monitoring Linux from Web Browser
Monitoring Linux from Web Browser

You can right-click to use several features and actions, including changing the look and feel of your shell.

Shellinabox Options and Usage
Shellinabox Options and Usage

For more information, visit the official Shellinabox github page.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

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.

87 thoughts on “Shell In A Box – A Web-Based SSH Terminal to Access Linux via Browser”

  1. It’s a very useful article for me who wants to make an IDE for a program language platform on the web.

    But How do you describe how to make it using a thin client PC via the web?

    Thanks.

    Reply
  2. I have two SSH services on same IP i.e on port 22 & 12344. Whenever I try to connect https://localhost:23167, I get connected to SSH server running on port 22. How do I connect to SSH services on port 12344?

    Kindly suggest.

    Reply
    • @Ujlain,

      You need to specify both port numbers in the sshd_config file, and use the port number to access the SSH, like:

      $ ssh user@baeldung -p 12344
      Or
      $ ssh user@baeldung -p 22
      
      Reply
  3. Good article, thanks. I found it more direct than some other pages on how to install shellinabox.

    What command did you use to generate the output shown in the second to last screenshot titled “monitoring linux from Web Browser”?

    Reply
  4. Why are there so many sentences on this page that make no sense at all?

    Make sure that your repository enabled and available to install Shellinabox from that repository.

    Reply
  5. Thank you very much for your guidance. It does work and is very useful. However, the command line

    sudo service shellinaboxd start

    was wrong in my Debian 9.11. I had to perform with the one

    sudo service shellinabox start

    and it works.

    Reply
  6. Hello, I installed shellinabox on a raspberry pi. Everything works with no problem. However I’m not a Linux guy I’m still learning. I was trying to figure out open ssl but I’m having trouble.

    Can someone help me to setup open ssl please?

    Joseph

    Reply
  7. Is there a way to modify the encryption and key exchange used by shellinabox? We would like to limit it to ECDHE ciphers.

    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.