I wanted a solution to have a shell on my web server in an environment where direct ssh connection was not possible or easy(like on my phone). I tried Ajaxterm some time ago but the solution was not perfect. Copy/paste was tricky to set and terminal scrolling not working properly. Shell In A box is the new perfect solution :)

description

I want to install shellinabox but i don’t want it to be directly accessible. I want it to go thorugh nginx where i could add some additional authentication and security check.

So i will configure it to listen on localhost only and after that configure nginx to give access through proxy.

package installation

On Ubuntu, it’s easy to install the package. Use aptitude :

aptitude install shellinaboxd

The only change in default configuration is to set up Shell In a Box to listen only on localhost.

We need to add the option –localhost-only in /etc/default/shellinabox

Here the diff :

root@krystalia:~# diff shellinabox.orig /etc/default/shellinabox
18c18
< SHELLINABOX_ARGS="--no-beep"
---
> SHELLINABOX_ARGS="--no-beep --localhost-only"

Start the service :

/etc/init.d/shellinaboxd start

It’s always good to check if the service listen on localhost :

adejoux@krystalia:~$ sudo netstat -lataupen|grep shellin
tcp 0 0 127.0.0.1:4200 0.0.0.0:* LISTEN 0 1437417 2631/shellinaboxd

nginx configuration

I assume nginx is already configured. So we only need to redirect the access. Find below the configuration to put in the server section of your site configuration file.

  location /shellinabox/ {
    rewrite ^/shellinabox/(.*) /$1 break;
    proxy_pass http://127.0.0.1:4200;
    proxy_read_timeout 90;
  }

Always check if your configuration is valid :

/etc/init.d/nginx configtest
* Testing nginx configuration [ OK ]

And reload nginx :

/etc/init.d/nginx reload