Using Browsh and a VPS to browse ‘bandwidth-free’?
Tired of switching between your terminal and browser windows? Reaching out for the mouse over and over again interrupts your thought process? Well then—Browsh is the perfect addition for you and your terminal. Browsh is a text-based browser that you can launch and use from within your terminal. It works like any shell-based utility, such as
vim editor or
top, works, but also displays websites in color and with the ability to point-and-click your way around.
Being entirely contained within the shell, Browsh opens up all sorts of possibilities. For example, we can install it on a VPS and browse the web using a server as a client!
Of course, servers like the ones we offer come with a lot of bandwidth, and browsing the web at those speeds is a delightful experience. You probably don’t have as quick a backbone to the internet at your own house. But using a VPS as a “route” to browse the web normally, such as connecting with VNC and launching a graphical browser doesn’t make sense. Your home internet and WiFi will bottleneck the speed anyway.
Get THE BEST DEALS IN CLOUD HOSTING from Los Angeles!Grab a huge 32GB RAM & 320GB of SSD storage for just $109/year!
But what if we combine the incredibly fast VPS bandwidth with SSH’s use of plain text to display information? Instead of showing us a high-resolution image, which would have taken a few MBs of transfer, Browsh will draw a rough pixelated approximation of the image with characters worth a few KBs.
An additional benefit is that using Browsh on your VPS will also act as an effective proxy server. You’ll obfuscate your internet traffic from your local ISP, as well as any other middleman trying to listen on your web traffic. It’s not quite the same as using a VPN, but SSH traffic is still strongly encrypted, and that does throw away a lot of meddling parties.
Let’s install Browsh on a VPS and see the effectiveness of this approach.
The installing browsh rather easy if you have Docker installed on your VPS. SSH into your VPS and you can spin up a Browsh container using the command:
$ docker run -dit --name shell-browser browsh/browsh $ docker attach shellbrowser
The first command pulls a browsh image and starts a container named
shell-browser, which runs with the flags:
-d so browsh can run in detached mode in background
-i for keeping standard input STDIN open
-t to attach a pseudo TTY to the container
The next command attaches your console to this container. And you are greeted by the Browsh homepage.
The top left corner shows the title bar, and below it, you can see the URL for that page.
If you don’t want to depend on Docker, you may have to install Firefox (as a dependency) on your VPS and then install Browsh. Check this page for the list of available downloads and use
wget followed by the download link to get a copy on your VPS.
Here we try and install it on an Ubuntu 16.04 LTS system.
$ sudo apt install firefox $ wget https://github.com/browsh-org/browsh/releases/download/v1.4.10/browsh_1.4.10_linux_amd64.deb $ sudo dpkg -i browsh_1.4.10_linux_amd64.deb $ browsh
Browsh uses keyboard shortcuts similar to any other browser. For instance, you can use
Ctrl+l to enter a URL or perform a Google search.
Ctrl+t will open up a new tab.
Ctrl+w closes a tab and if only one tab is open,
Ctrl+w closes the Browsh session and returns you to the shell prompt.
Let’s try to open a new tab and visit
Google.com with it, use the shortcuts described above. We can click on the search bar and look for a query like
Flag of Denmark and hit
<Enter> to see the result.
You can, of course, visit a Wikipedia page where you can learn that this flag, called Dannebrog, has been the oldest continuously used flag in the world.
That’s some quick vexillology from inside a shell!
As you can imagine, audio or video playback is not an option with Browsh unless you have it locally installed on your workstation, where it can take advantage of the Firefox backend and audio and video capabilities.
I have been using it for reading text and having a quick cursory glance at written content like documentation pages as I work on something else in the shell.
You can leverage Browsh particularly well if you are using Tmux to open multiple terminals at once. You can keep Browsh open on one of these subwindows to do a quick Google search of some documentation as you work away on the shell.
On the server itself, we can run a quick benchmark using a utility like
nethogs, which shows how much bandwidth different processes are utilizing. We can compare the total data received by the Firefox process (which is what Browsh uses) and compare it against the total data sent over SSH which will be received on our end. Let’s install and run nethogs.
$ sudo apt install nethogs $ nethogs
m you can toggle between usage per second (KB/s) to total data transfers in KB. Now we need to run Browsh in a different shell and enter the URL for any popular Speedtest in it.
Note: If you are using the Speedtest by Ookla, you may have to click on
Go, which might be difficult to see in Browsh.
In our test, as the speedtest progressed, I noticed that while Firefox received over 1GB of data, the SSH process sent only a little over 2MB via Browsh!
But this was just a brute force test—what about browsing Wikipedia, as we did before?
After visiting Wikipedia.org and browsing various articles for a few minutes, this was the result.
The VPS consumed 1836.693KB via Firefox, but Browsh sent me 12836.289KB via SSH! Somehow, instead of being efficient, as I had assumed, Browsh ended up costing me more data. What’s going on here?
This fun experiment itself sheds a lot of light into the complexity that is built into nearly every website you visit. No benchmark can give you an absolute answer, but it can help you make decisions between what technology will fit your use case.
Even scrolling down and going back up in Browsh requires additional bandwidth. This is because an entire stream of bits will be sent from your VPS carrying information about the bottom of the page every time you scroll down. And once you scroll back up, Browsh needs to send that data all over again. A regular browser downloads a page once and lets you scroll up and down freely without any more downloading or processing.
Lastly, traditional browsers use cache a lot, which would also dramatically tilt the scale in their favor, even when multimedia playback is involved.
In any case, the point of Browsh is not to substitute the traditional browser, but to have a fresh application to tinker with and appreciate the sheer ingenuity and complexity of the systems we take for granted.
Plus, it’s way less distracting than having an open browser window.