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.

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.

88 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
    • @Prudhvi,

      Because, shellinabox works on TCP port 4200 and for security reason, I change this default port to a random (i.e. 6175) to make it difficult for anyone to reach your SSH box.

      Reply
    • Unfortunately it cannot. Only one service can listen to a port (e.g. 443) at a time. It can be either Shellinabox OR Apache, but not both at the same time.

      Reply
      • You can use it together with apache with a extra config like this in the sites-available:
        I typed it over, so maybe the config is not exact, but this works

          proxypreservehost on
          proxypass  "/" "https://youropenboxserver:4200/"
          proxypassreverse "/" "https://youropenboxserver:4200/"
          servername  ssh.yoursite.com
        

        restart apache and you have an extra entry for https :)

        Reply
        • Oh, right, via Apache’s internal proxy config. That didn’t occur to me. The lines above will probably have to go between tags though to limit it to https only (and the certificates will have to be configured as well of course).

          Reply
    • @Esteban,

      If it’s available for Windows platform, then you can install it, just check their download page and see whether its available for all architectures..

      Reply
  8. 1- How to SSH shellinabox using Javascript?
    2- Is it required to have a SSL certificate?
    3- Needed it because I want to pass commands from Client side to the server side(Shellinabox web server).Any help?!

    Reply
  9. Hi,

    How can I configure shellinabox for auto-login?

    For example when I access my server:port for shellinabox – I want it to sign in automatically to the root user and run a predefined script. (I already configured the script correctly – you cannot ctrl +d or ctrl+c from it – and when it ends, it throws you out of the root user session without the possibility of getting back to it).

    Thanks,
    Razvan

    Reply
  10. Hi Ravi, I have the similar requirement but I can not really install shell in a box at remote machines. We have restrictions we can not ask client to install that. But we need provide web based ssh terminal user will enter credentials to login. Do you know how this can be done?

    Reply
      • but this needs to be installed on the server. This i can not do because those servers are remote and owned by different people. Can i have something without setting up on server?

        Reply
        • @Kiran,

          How can you have something without setting up? not possible, you need to have a tool in place to achieve the same..I hope you understand..

          Reply
          • Thank you Ravi for confirming. I had the same thought but i was still searching for options since i have the requirement in my application. Now i have expert input, will have to find other alternatives.

  11. Hi, I tried to install this on my centos server and there is only one user root.
    I didn’t make change to config file and tried to start it.
    It gives error below, am I missing something?
    Starting shellinaboxd: [server] Cannot look up user id “-g”!
    [FAILED]

    Reply
    • @Henry,

      On which version of CentOS you’re trying to install Shellinabox? the error seems new to me and also there isn’t any information about such error on web.

      Reply
  12. Hi! I just have installed it on my server and will try it out when I am back in the company. Two comments:

    1. In the installation doc above on this web page you say “Starting Shellinabox” with “sudo service shellinaboxd start” but its should be “sudo service shellinabox start” without the “d”.

    2. Can I restrict shellinabox for only one single user account? I’d like to prevent the root accounts from being attacked with brute force attacks through the browser.

    -wbr, Andreas

    Reply
    • @Andreas,

      Thanks for findings, but different Linux OS provides different deamon names for example, in CentOS you will get shellinaboxd and whereas in Ubuntu you will get without ‘d’ at the end..

      And about user restriction in shellinabox, no idea about it, I think you should read its configuration to know more about it, might be there is a way to do it..

      Reply
  13. This sounds awful to me! Any idea what port I can use, when sitting behind a firewall that blocks almost all of th ports?

    Reply
    • @Andreas,

      May I know on which Linux distribution you were trying? have you opened port on the firewall? or have you changed default port to custom in /etc/default/shellinabox file?

      Reply
      • The targeting distribution is Ubuntu, but the problem is on the site I’m trying to access it from. The company I’m in is blocking almost all outgoing traffic. Not even sure if I could use 443, because I don’t own an official certificate. Maybe 8080 could be an option, not even sure about this. (in fact there is no information about what’s blocked). So best would be if I could use a subnet web page (on port 80) instead of using a different port. I wonder if using a subnet page and mapping it with htaccess to another port on my server, but I have to admit I’m not familiar with this stuff… Any idea?

        Reply
        • @Anreas,

          Sorry, but I don’t think that would be possible to allow a subnet in shellinabox configuration, let me check and get back to you if I found any solution..

          Reply
  14. great, just I need to know where the service put the log file in case is active? this is beause I have fail2ban, and I want to have the rules. Thanks anyway

    Reply
  15. Thank you very much for this useful posting.
    My problem is, that I can only use the port 443 via browser.
    I can not call https://IP:4220 but only https://IP (which is :443) – because of firewalls.
    I have on my root server some virtual hosts.
    How I can configure the Apache on one particular virtual host getting the requests https://IP forwarding them to the ShellInABox?

    Reply
  16. Hi There, Now I’m using Shellinabox on my server, I want to record all the operations on the server by shellinabox, and write then to the dababase. It seems shellinabox is wroten with C, I can’t find the variable of username and user’s input. Could you give me some tips? Thank you very much!!!

    Reply
  17. It seems like shellinabox works fine for localhost but do not forward ssh session to destination remote host.
    Scenario: my setup has two servers: Server A with eth0 (public ipaddress) and eth1 (private ip address) and server B connected to eth1 of server A.
    Both server A and B has sshd running. Shellinabox is running on server A alognside apache2. Getting to server A ssh server through https is nto an issue but ssh session to server B is not working. I have modified /etc/default/shellinabox with destination ipaddress of server B for ssh session, but it is not working. Any help would be greatly appreciated, perhaps I am not using correct commands to include destination ipaddress and username and port number for remote SSH server (server B).
    Thanks
    Dhiman

    Reply
    • @Jeya,
      I don’t think it support private key feature, but you can restrict access to specific IP address on specific port….

      Reply
  18. @Craig – useful for remote access. My employers block all ports outbound except web via proxy which does ssl termination For packet inspection.

    Hopefully this will work to access my machines at home

    Reply
  19. Why? What is wrong with ‘ssh’ from the terminal. So you are installing an additional server on your system just to support something it should already do?

    I don’t get it!

    Now if its just for the, hey I am a hacker and I like to do bizzarre stuff … then that makes some sense :o)

    Craig

    Reply
    • For example I want to access to my server while I am playing. Steam does not allow own apps (like PuTTy) on Steam overlay -> I want to check IRC/Facebook chat (via BitlBee on my server) when I am waiting to CS:go round to end.

      Reply
  20. Report at step <>

    LSB_RELEASE NOTE
    Ubuntu 14.04 LTS
    ….

    CONFIGUREATION
    SHELLINABOX_ARGS=”–o-beep -s /:SSH:myIpAddr –localhost-only”

    ERROR
    sudo service shellinabox start
    /usr/bin/shellinaboxd: unrecognized option ‘–o-beep’

    CHANGE
    I change the option to ‘–no-beep’ it is OK.
    SHELLINABOX_ARGS=”–no-beep -s /:SSH:myIpAddr –localhost-only”

    Reply
  21. Does not seem to work on RedHat 6.1 even though the installation and verification works fine. I can see the port is listening but cannot establish connection from outside the server.

    Reply
  22. hello people

    i am trying configure the keyboard for to use the letter Ñ, because i am in mexico, whats parameters i need to use and which files will be changed?

    Reply
  23. When I try to execute the command
    I met with the following error
    #service shellinaboxd start
    Starting shellinaboxd: Cannot look up user id “-g”
    But if i check the #service shellinaboxd status
    It displays shellinaboxd is stopped
    Any idea how to start it?

    Reply
    • Did you ever figure this out? There doesn’t seem to be any real information on this. I can start it by executing it in the foreground but for some reason the service doesn’t want to work.

      Reply
    • Got it up and running by using the following;

      /etc/init.d/shellinaboxd start
      After adding the following to /etc/sysconfig/shellinaboxd

      USER=
      GROUP=
      CERTDIR=/var/lib/shellinabox

      in addition to the ones specified above.

      Reply
  24. Nice post, worked fined for me :-)

    I’m connecting from Ubuntu, it’s working from Firefox but not from chrome (nothing’s display on chrome…)

    So if you have problem with chrome have a try with another brother.

    Reply
  25. Hello.
    Thanks for this good article.
    Maybe you can tell where to look for
    My server is a Centos linux box
    When I do the connection I get:
    181 login:
    I type root
    The prompt for Password never appears.
    Any idea?

    Reply
  26. Didn’t you have a problem starting shellinabox on Debian? When i installed it from reposotory (apt-get install) it had worked fine until I restarted the mashine and then it can not be start automaticly.
    It also can not be start by command service shellinabox start, producing the error message Cannot look up group “shellinabox”.

    Has anybody faced this problem yet?

    Reply
  27. Thanks for the article. I need to run a shell script on a remote machine (BOX A) interactively from the browser (Client). Currently, i am able to run a script on a remote machine (BOX A) using the php and ssh running on appache webserver(BOX B). The php is on a webserver(BOX B) and Shellscirpt on remote machine (BOX A). But I need to key any input/prompt that needs user input, i can;t get to the remote machine. Can you please tell me how to achieve this.

    Reply
  28. When I type my username then press enter it will automatically closed session then I have to click the connect the button again then again and again and again….

    Reply
    • It does require a public IP address as any other public Internet service (e.g. web, FTP, SMTP etc.), but it doesn’t have to be a fixed IP. You need to know the system’s current IP in order to be able to connect though of course….

      Reply
  29. Thanks for this article. I wanted to point out that to start it up on RHEL and CentOS you need to add the “d” at the end, thus

    “service shellinaboxd start”

    Reply
  30. Hi Ravi, another great post!

    I’m using Ubuntu 12.04.3 LTS and the apt-get install openssl shellinabox didn’t work (i checked everything with the repositories and everything was ok.

    To install it, i did this:

    # wget http://archive.ubuntu.com/ubuntu/pool/universe/s/shellinabox/shellinabox_2.14-1_i386.deb (for the 32bit version)

    #dpkg -i shellinabox_2.14-1_i386.deb

    Got this tips from: http://www.linuxplained.com/install-shellinabox-on-ubuntu/

    Keep up the good work!

    Reply

Leave a Reply to Razvan Cancel reply

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.