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.

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.

Installing Browsh on your VPS

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.

Browsh: Looking at 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

Using 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.

Browsh: Time to Google!

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.

Browsh: The flag of Denmark Wikipedia page

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.

Does using Browsh really cut your bandwidth usage?

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

By pressing 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.

Browsh: Starting a speedtest

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!

Browsh: The speedtest bandwidth results

But this was just a brute force test—what about browsing Wikipedia, as we did before?

Browsh: Bandwidth usage when browsing Wikipedia

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?

Benchmarks are not the real world

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.

For example, if a website uses a lot of client-side JavaScript, you will notice that the page is much slower and unresponsive over Browsh. That’s because the actual browser is running far away in your VPS. Every time you click a button or trigger an animation, that click event is sent all the way to your VPS, which runs the client-side JavaScript, and then Browsh sends the output back to you.

Regular browsers will fetch the JavaScript once and do this computation locally in your browser. You shouldn’t feel any delay, and it won’t tax your network either.

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.

Browsh: Using it in real life