-
SHELLINABOX ou comment faire du SSH via HTTP et le WEB
SHELLINABOX permet de se connecter à un ordinateur distant en SSH par l’intermédiaire du HTTP et donc, d’un navigateur Web.
INSTALLATION
sudo apt-get update sudo apt-get install shellinabox
Éditer le fichier
/etc/default/shellinaboxen changeant cette ligne :SHELLINABOX_ARGS="-s/:LOGIN -t --no-beep"
Puis redémarrer SHELLINABOX :
sudo /etc/init.d/shellinabox restart
Créer un user pour le premier login :
adduser acme
Ouvrir le navigateur WEB à cette adresse :
http://adresse_IP:4200, on doit voir le prompt pour le login.Utiliser le login du user acme et utiliser les privilèges d’administrateur en changer le user en root :
suPROBLÈMES
Au cas où ça ne marche pas via internet en https, essayer en local avec une adresse du genre
https://192.168.0.66Firefox vous dira que le site est mal configuré. Cliquer sur Avancé. Puis créer une exception. Là, shellinabox devient accessible.
On peut maintenant aller à l’adresse internet : https://111.222.333.444, et faire la même manip : Avancé > Créer une exception.
CSS
Pour créer soi-même le CSS et donc l’aperçu, ajouter et éditer un fichier dans /etc/shellinabox/ .
Changer cette ligne dans /etc/default/shellinabox :
SHELLINABOX_ARGS="-s/:LOGIN -t --no-beep --static-file=styles.css:/etc/shellinabox/TEST.css"Puis redémarrer shellinabox :
/etc/init.d/shellinabox restartLe fichier CSS :
#vt100 #scrollable{}-#vt100 #scrollable.inverted{}- inversé ou négatif#vt100 .bgAnsiDef{}Background pour le texteCouleurs du texte
#vt100 .ansi0→ couleur pour le#vt100 .ansi1→ couleur pour le Rouge#vt100 .ansi2→ couleur pour le Vert (ligne 9)#vt100 .ansi3→ couleur pour le Jaune#vt100 .ansi4→ couleur pour le Bleu (ligne 11)#vt100 .ansi5→ couleur pour le#vt100 .ansi6→ couleur pour le Cyan#vt100 .ansi7→ couleur pour le#vt100 .ansi8→ couleur pour le GRAS (font-weight:bold)#vt100 .ansi9→ couleur pour le Rouge BOLD (font-weight:bold) ligne 16#vt100 .ansi10→ couleur pour le (font-weight:bold)#vt100 .ansi11→ couleur pour le (font-weight:bold)#vt100 .ansi12→ couleur pour le (font-weight:bold)#vt100 .ansi13→ couleur pour le (font-weight:bold)#vt100 .ansi14→ couleur pour le (font-weight:bold)#vt100 .ansi15→ couleur pour le (font-weight:bold)Couleurs du fond
#vt100 .bgAnsi1 { background:transparent} → couleur pour le #vt100 .bgAnsi2 { background:transparent} #vt100 .bgAnsi3 { background:transparent} #vt100 .bgAnsi4 { background:transparent} Fond Bleu #vt100 .bgAnsi5 { background:transparent} #vt100 .bgAnsi6 { background:transparent} #vt100 .bgAnsi7 { background:transparent} #vt100 .bgAnsi8 { background:transparent} #vt100 .bgAnsi9 { background:transparent} #vt100 .bgAnsi10 { background:transparent}
#vt100 .bgAnsi11 { background:transparent} #vt100 .bgAnsi12 { background:transparent} #vt100 .bgAnsi13 { background:transparent} #vt100 .bgAnsi14 { background:transparent}
body {}
#vt100 a {}
#vt100 a:hover {} #vt100 #reconnect {} #vt100 #reconnect input {} #vt100 #cursize {} #vt100 pre {} #vt100 pre pre {} #vt100 #scrollable {} #vt100 #console, #vt100 #alt_console, #vt100 #cursor, #vt100 #lineheight {} #vt100 #lineheight {} #vt100 #cursor {} #vt100 #cursor.bright {} #vt100 #cursor.dim {} #vt100 #cursor.inactive {} #vt100 #padding {} #vt100 .hidden {} #vt100 #menu {} #vt100 #menu .popup {} #vt100 #menu .popup ul {} #vt100 #menu .popup li {} #vt100 #menu .popup li.hover {} #vt100 #menu .popup li.disabled {} #vt100 #menu .popup hr {} #vt100 #menu img {} #vt100 #scrollable.inverted {}
—
how to install SSH server on Ubuntu.
Before we begin, it is good to know how to start, stop, and restart Shellinabox and Apache. Use the following commands to restart Shellinabox and Apache:
sudo service shellinabox reload sudo service apache2 reload
To find out how to start, stop, and restart Shellinabox using simple and convenient aliases, refer to this post.
1. Change default listening port
Shellinabox by default listens on port 4200.
edit
/etc/default/shellinabox
Find the lines below and change the port number from the default 4200 to another random port (eg. 6125):
# TCP port that shellinboxd's webserver listens on SHELLINABOX_PORT=6125
Save and exit.
Restart Shellinabox.
Your Shellinabox should now be available at
http://localhost:6125
.If you have setup port forwarding on your router/DHCP server, you can access your Shellinabox using
http://XXX.XXX.XXX.XXX:6125
, where XXX.XXX.XXX.XXX is your external IP address.2. Enable SSL
To enable and enforce HTTPS access on Linux servers with Apache, install the following run-time libraries:
sudo apt-get install libssl0.9.8 libpam0g openssl
Restart your Shellinabox and Apache server. It should now be accessible only through
https://localhost:6125
. Note that you may have to have a SSL certificate generated. Refer to Apache documentation if you want to generate your own certificate. By default, the system will install self-signed certificates for you. These certificates are likely to raise warnings when you point your browser to the site.3. Restrict Shellinabox to Localhost Only
edit
/etc/default/shellinabox
Find the line below and add
--localhost-only
at the end (as shown below):SHELLINABOX_ARGS="--no-beep --localhost-only"
Save and restart Shellinabox.
While this can increase Shellinabox security, it will prevent access to your Shellinabox from others systems and remote access through the internet. This can be a great inconvenience. You can overcome this drawback by setting up Apache reverse proxy as described in Step 4.
5. Enable Apache Authentication
Last but not the lease, enable Authentication. Every time you access Shellinabox, you will be asked for a username and password as shown in the picture below:
To do this you will, first have to create a
.htpasswd
file. More information is available in Apache documentation. But the easiest way to achieve this is to use one of the htpasswd generators available online.After you enter the username and password two code blocks will be generated. Copy the contents of the
.htpasswd
code block and save it to/etc/apache2/.htpasswd_siab
.Next, copy the contents of the
.htaccess
code block and add it to/etc/apache2/mods-available/proxy.conf
as shown below:ShellInABox Reverse Proxy (text)
Save and exit.
Restart Shellinabox and Apache.
You should be prompted for a password everytime you try to access Shellinabox.
After you are done with all the configuration/editing, run the following command to ensure that your new Shellinabox defaults are updated:
sudo update-rc.d shellinabox defaults
Restart your Apache and Shellinabox one last time. Each step adds one additional layer of security. Together they increase your Shellinabox security and make it nearly impervious.