Shellinabox - terminal in the browser

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Shellinabox - terminal in the browser

Postby viking60 » 25 Oct 2015, 13:44

I came across shellinabox and it basically makes your browser a terminal.

It also provides SSL by default. You can make self signed certificates or simply accept the exeption when your browser complains about the certificate (it is still secure because you know you are you :-D ).

So why use this?

Well sometimes it can be nice to have some more space for reports and scripts.
CLI programs like glances, iftop and Atop need some more space than a traditional terminal.

So to test it I compiled shellinabox-git from the AUR.

Then I simply started it with

Code: Select all

shellinaboxd

This started the daemon in "live mode" so I wen to my browser and typed https://localhost:4200
(4200 is the default but you can change it)
..And there my terminal was.

I fired up atop and htop and everything worked just like in the terminal.
But in my real terminal shellinaboxd was running so to stop it I had to do a CTRL+C.

When you do that there is no way of restarting it again because the port 4200 will be taken no matter how much you kill shellinaboxd. The port 4200 is taken so you cannot start it again. :berserk2
(booting the computer will take care of it - I cannot figure out any other way of doing it).
This slight annoyance is typical and happens with all programs that use a port, so it is not shellinabox specific.

So it makes sense to start shellinabox in the background so you do not have to cancel it in your terminal.
You can do this by simply typing

Code: Select all

shellinaboxd -b

Now your terminal will be free for use and shellinabox is running so you can go to the browser and type localhost:4200.

...
I noticed that programs like inxi and glances did not show all that well on the white browser background so I decided to hook this up with a stylesheet that made the background black with greenyellow fonts so I created black.css with these data:

Code: Select all

body {
   background: black;

   color: greenyellow;
}

if this is in the same directory where you start your shellinabox from the colors will be adjusted. You can specify an address if this is not the case.
So if you put the stylesheet black.css in ~/public_html this would be how to start shellinabox in the background:

Code: Select all

shellinaboxd -b --css ~/public_html/black.css

And now my binfo script and inxi etc look good in my new browser terminal:
:A
Image

Naturally you can run this on other servers in the network - it does not have to be localhost.
All commands work just like in the terminal also within glances, htop etc and you get an additional right-click menu.

Here I have iftop running in Chromium:
:A
Image


Centos has shellinabox in the epel repo. Fedora has it in the repos. Debian 8 has it in the repos. Mint has it in the repos. That means that most distros have it - Mageia doesn't though.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Shellinabox - terminal in the browser

Postby dedanna1029 » 25 Oct 2015, 23:51

*raises eyebrows

Think I'll go get it and compile it in Mageia... this is cool.
Mageia doesn't have inxi either so I'll have to do the same with it.
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Shellinabox - terminal in the browser

Postby viking60 » 26 Oct 2015, 00:35

Sure there must be a Fedora rpm that fits.
Inxi is in the repos now - my little revolt over there lead to it :boohoo: :-D
Even inxi -r works and indicates the repos. So those guys have seen the light. :idea:

Code: Select all

[berserk@localhost ~]$ inxi -r
Repos:     urpmq repo: Core Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/core/release
           urpmq repo: Core Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/core/updates
           urpmq repo: Nonfree Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/nonfree/release
           urpmq repo: Nonfree Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/nonfree/updates
           urpmq repo: Tainted Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/tainted/release
           urpmq repo: Tainted Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/x86_64/media/tainted/updates
           urpmq repo: Core 32bit Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/core/release
           urpmq repo: Core 32bit Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/core/updates
           urpmq repo: Nonfree 32bit Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/nonfree/release
           urpmq repo: Nonfree 32bit Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/nonfree/updates
           urpmq repo: Tainted 32bit Release
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/tainted/release
           urpmq repo: Tainted 32bit Updates
           rsync://ftp.acc.umu.se/mirror/mageia/distrib/5/i586/media/tainted/updates

And I must admit that I quite like shellinabox.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
dedanna1029
Sound-Berserk
Posts: 8780
Joined: 14 Mar 2010, 20:29
Contact:

Re: Shellinabox - terminal in the browser

Postby dedanna1029 » 26 Oct 2015, 01:20

Yeah, I'm going to try that later on tonight.
However, if shellinabox isn't in the repos, I'd rather compile it.
It's kind of a "thing" with me. Back in the days when the Mandriva/Mageia rpms didn't work and were buggy for Clementine (among other proggies), I would compile it and it would work fine.
I'm going to see what this takes.

Thanks! :)
I'd rather be a free person who fears terrorists, than be a "safe" person who fears the government.
No gods, no masters.
"A druid is by nature anarchistic, that is, submits to no one."
http://uk.druidcollege.org/faqs.html


Return to “Tips & Tricks”