Routing internet via SSH tunnel on Raspberry Pi

2015-07-25 Linux, Network, Raspberry Pi, Ubuntu No comments

Problem overview

Recently I had the following problem. I wanted to connect to my Raspberry Pi from my laptop. For some reason WiFi dongle on the Raspberry Pi was not working properly. Moreover, I had only one slot available for the LAN connection via cable to the router, so I could connect only one device this way. I wanted to have reliable and fast internet connection on my laptop, but via WiFi it’s quite slow.

To sum the things up two goals were clear:

  1. to have fast and reliable internet connection on the laptop
  2. to be able to connect to Raspberry Pi via SSH in order to control it from the laptop

Enabling SSH server on Raspberry Pi

Before we proceed to the next steps, we need to enable SSH server on Raspberry Pi if we haven’t done it in the past.
In order to do that, we need to go through the following steps:

  1. login with the following information when prompted:
    username: pi
    password: raspberry
  2. type the following command in the terminal: sudo raspi-config
  3. then navigate to ssh
  4. hit Enter
  5. select enable ssh server
  6. reboot device
  7. we are done!

Sshuttle to the rescue

I tried a few different approaches to solve described problem, but up to now the only one solution satisfies me well.
I’ve found discussion starting with the question How do I route my internet through a SSH tunnel? In this discussion, I’ve read about great tool called sshuttle, which works as a poor man’s VPN.

sshuttle is a transparent proxy server that forwards over a SSH connection and sets up a proxy by running Python scripts on the remote server. sshuttle can be run under the following conditions:

  • client machine or router is Linux-based, FreeBSD or Mac OS
  • administrative privileges on client
  • access to remote network via SSH
  • no administrator privileges on remote network
  • availability of Python on remote server

sshutle can be installed with the following command:

sudo apt-get install sshuttle

The basic command for running sshuttle with routing all traffic is:

sshuttle -r username@sshserver:port 0/0

Upon the execution of the command, a sudo password prompt will appear and subsequently the password to SSH account. No other details will appear except for a short message and return to shell upon failure. For more status messages, run sshuttle in verbose mode with the -v flag.

In this example all internet traffic except DNS is routed through the VPN. -r flag denotes the remote hostname and optional username and port that follows in the above example. 0/0 is short for that represents the subnets to route over the VPN. The usage of 0/0 routes all the traffic except DNS requests to the remote server. DNS tunelling is possible with the usage of -H flag.

Please read the man page (man sshuttle) for the details of options and modes under which sshuttle can run. For information about the concept and more examples, refer to the project page.

– André Paramés on

Connecting to Raspberry Pi and tunneling internet connection

Luckily, all requirements were satisfied by Raspberry Pi and I could use it with sshuttle, so I’ve installed this software on my laptop.
I’ve connected to my local network through WiFi. Then, I’ve scanned network with nmap to find IP of Raspberry Pi.

nmap -sP

My local network consists of only few devices and each of them has a description, so I could easily identify IP of the Raspberry Pi.
Output looked like this:

Nmap scan report for livebox.home (
Host is up (0.0070s latency).
Nmap scan report for laptop-piotra-*samsung-ultrabook*.home (
Host is up (0.00011s latency).
Nmap scan report for pc36.home (
Host is up (0.018s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 2.64 seconds

Right now, active devices in my network are: router, my laptop and Raspberry Pi, with IP:
After that, I connected to Raspberry Pi with the following command:

sshuttle -r pi@ 0/0

It asked me about the local password and then about the password of remote host, which is raspberry by default and I saw the following message:


Everything was fine. I was connected to Raspberry Pi and I was able to access internet through it.
Next, I opened another terminal window and tried to connect to Raspberry Pi via SSH.
Please note, that you have to enable remote access via SSH on Raspberry Pi before you try to establish connection.

When SSH is enabled, you can type the following command:

ssh pi@

Then I typed correct password and I was connected!

Linux raspberrypi 3.18.7+ #755 PREEMPT Thu Feb 12 17:14:31 GMT 2015 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jul 25 01:49:00 2015 from pc36.home

Short summary

What is surprising tunneled internet connection was fast and stable when I was accessing it through Raspberry Pi.
When I was accessing internet directly through WiFi on the router it was really slow for some unknown reason.
Luckily, I’ve achieved my goals: I’ve fast internet connection on the laptop and I coul establish SSH connection with Raspberry Pi over local network.

Glances – light, but powerful system monitoring

2015-07-11 Devops, Linux, Python No comments

Recently, during reading information in The Art of Command Line repository, I’ve found Glances, which is a cross-platform curses-based system monitoring tool written in Python. It’s light, but very powerful tool, which allows to monitor your system. Moreover, it’s open-source.


Before you install Glances, you need Python, PyPI and Psutil. If you want to run Glaces as a web server, you also need to install Bottle.
To monitor temperature of your CPU, install Pysensors.

You can install the most important packages with the following command:

$ sudo pip install psutil bottle pysensors

and then install Glances

$ sudo pip install glances

After that, just run glances

$ glances

If you want to run Glances as a web server, type:

$ glances -w

open the following address in your favorite web browser: http://<your_ip>:61208/ and replace <your_ip> with appropriate value.
If you just want to check it locally, you can use this address:

Oh My Zsh!

2015-07-01 Linux No comments

If you are Unix user and don’t use Oh My Zsh, you should definitely start. Oh My Zsh is a framework for Zsh, the Z shell.
It has many plugins and great community. Actually, it’s enhanced and more intelligent terminal. I find it very useful while working with Git. It’s much more comfortable than via default Ubuntu shell. In addition, you can customize its look & feel. My favorite theme is minimal. It’s just a piece of functionality of this tool, you can discover much more by yourself.


You can install Zsh in the following way:

$ sudo apt-get install zsh

To set it as your default shell type:

chsh -s /usr/bin/zsh

Now, you can install Oh My Zsh via the following command:

$ curl -L | sh

Project is open-source. You can find it on GitHub:
Visit official website at:

Automation of basic software installation on Ubuntu

2015-06-30 Linux, Ubuntu No comments

Recently, I had to re-install my system again and I didn’t want to go again through manual installation of software I use daily. Due to this fact, I decided to create shell script, which will download, install & configure software for me. It can be executed right after installing Ubuntu. Please remember, this applies to my configuration and may be not appropriate for yours (e.g. drivers for wireless Logitech headset). This script won’t install IDEs & editors like: Android Studio, IntelliJ IDE, Pycharm and Atom. You can download them manually from their websites. I realize, not everything is automated and we will have to confirm a few installations manually. Moreover, script won’t do everything I need. Nevertheless, it performs a lot of work for me and in case of system re-installation I can re-use this solution.
If you want to know more about software installed with this script, browse Linux & Ubuntu categories on this blog.

You can run the script with the following command:

$ curl -L | sh

Mutate – yet another Spotlight for Ubuntu

2015-04-06 Linux, Ubuntu No comments


Some time ago, I published post about Synapse indicator, which is an alternative to MAC’s Spotlight for Ubuntu. Recently, I’ve found another software, which is in my opinion even better than Synapse. It’s called Mutate. I like it, because it works quite smooth, looks simple and clean. In addition, it’s open-source.



We can install it with the following commands:

sudo add-apt-repository ppa:mutate/ppa
sudo apt-get update
sudo apt-get install mutate


After installation, we can run Mutate from Ubuntu dashboard or via default hot-key CTRL+D and type preference.


After that, we can configure default hot-key for muate. E.g. CTRL+Space as on the screen below or another hot-key, which we prefer.


This configuration is saved in ~/.config/Mutate/config.ini file and we can edit it manually. Manual editing is, in my opinion, more convenient, because GUI of Mutate preferences seems to be buggy and config.ini file is quite readable. After editing of the file, changes are available in Mutate immediately without any reboot. We can also add more shortcuts and create our own python or shell scripts in ~/.config/Mutate/scripts/ directory or create references to scripts in other places.


Making Ubuntu and Unity faster

2015-03-28 Linux, Ubuntu No comments

Unity desktop environment consumes lot of computer’s memory. I’ve recently found good article about
4 simple tweaks to improve Unity performance on Ubuntu.

Here is the short summary of that tweaks:

Remove Unwanted Lenses

It will speed up loading data under “Super” button.

sudo apt-get autoremove unity-lens-music unity-lens-photos unity-lens-gwibber unity-lens-shopping unity-lens-video

Install Compiz Config Settings Manager

sudo apt-get install compizconfig-settings-manager

In Compiz Config Settings Manager perform the following operations:

  • Disable Animations and Fading windows
  • Set the Texture Filter to “Fast”

After that OS won’t use additional resources for performing animations.

Install Preload

sudo apt-get install preload

Preload analyzes applications, which are currently used and predicts, which applications might be used. After proper analysis, it loads to memory commonly used software. That process can drastically boost speed of loading programs and overall Ubuntu performance.

Adjusting Look & Feel of IntelliJ IDEA and Android Studio on Ubuntu

2015-03-28 Linux, Tools, Ubuntu 3 comments


In contrast to MS Windows, default installation of IntelliJ IDEA, Android Studio and other JetBrains IDEs, in my opinion, doesn’t look good in Ubuntu with Unity. Unfortunately, adjusting look of my favorite IDE is a common problem right now and it was reported to JetBrains issue tracker. Luckily, we can perform a few tweaks, to improve its look & feel ourselves.

Enabling HUD

Some Java applications don’t have Head Up Display (HUD) enabled by default. The same problem occurs in IntelliJ IDEA. I’ve described that in article about software for common users on Ubuntu. HUD is characteristic element for Unity environment and it’s similar to Apple OS X. I think, it’s useful and allows to have more space on the screen. In addition, I wanted my IDE to behave in the same way as other applications. In order to enable HUD, we have to install additional software:

sudo add-apt-repository ppa:danjaredg/jayatana
sudo apt-get update
sudo apt-get install jayatana

Hint: We can skip this step if we’re using different Windows Manager than Unity (e.g. Gnome).

Font fix

IntelliJ IDEA has problem with font anti-aliasing on Ubuntu. In order to resolve that problem, we need to install Font Fix for Open JDK.

sudo add-apt-repository ppa:no1wantdthisname/openjdk-fontfix
sudo apt-get update
sudo apt-get install openjdk-7-jdk

Preparing run script

To finalize font fixing process, we need to prepare additional shell script, place it in the bin/ directory with the IDE and run IntelliJ IDEA with that script. Below, I present source of my scripts for IntelliJ IDEA and Android Studio. We can create scripts for other JetBrains IDEs (e.g. PyCharm) in the same way.

# change to your location
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

# Note: Can modify $IDEA_HOME/bin/idea{,64}.vmoptions
# instead of setting here.
# "-Dawt.useSystemAAFontSettings=on" seems worse to me
# "-Dsun.java2d.xrender=true" makes fonts darker
export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=lcd \
                      -Dsun.java2d.xrender=true \
                      -Dswing.aatext=true \
# Having this set makes menu font size smaller (wtf?)
export GNOME_DESKTOP_SESSION_ID=this-is-deprecated
exec $IDEA_HOME/bin/ "$@"

# change to your location
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

# Note: Can modify $ANDROID_STUDIO_HOME/bin/studio{,64}.vmoptions
# instead of setting here.
# "-Dawt.useSystemAAFontSettings=on" seems worse to me
# "-Dsun.java2d.xrender=true" makes fonts darker
export _JAVA_OPTIONS="-Dawt.useSystemAAFontSettings=lcd \
                      -Dsun.java2d.xrender=true \
                      -Dswing.aatext=true \
# Having this set makes menu font size smaller (wtf?)
export GNOME_DESKTOP_SESSION_ID=this-is-deprecated
exec $ANDROID_STUDIO_HOME/bin/ "$@" 

Configuring fonts & appearance

I wasn’t satisfied by default font configuration of IntelliJ IDEA and Android Studio, so I updated it a little. In my opinion, it looks better after such operation. You can see my configuration on the screenshots below. Screenshots are from Android Studio, but configuration can be the same for all JetBrains IDEs. Of course, I also prefer Darcula theme.



Finishing configuration & system reboot

When we performed all of the tasks mentioned in the steps above, we need to perform reboot of the system. After that, our IDE and its fonts should look fine. That’s it. I hope it will be helpful for you.

Synapse Indicator – Spotlight for Ubuntu

2014-12-27 Linux, Ubuntu 3 comments


If you were using Ubuntu for some time, you might have noticed that Ubuntu Dash from Unity is working quite slow. We can disable on-line search or a few other elements, but it’s still very slow. If we want to have fast search, we can use external software like synapse.


Synapse is searching really fast and we don’t have to wait a few seconds like in Ubuntu Dash or disable some search options.


Synapse can be installed with the following commands:

sudo add-apt-repository ppa:synapse-core/ppa
sudo apt-get update
sudo apt-get install synapse

After installing it, in Synapse Preferences we can set appropriate shortcut for opening Synapse.

Synapse Indicator

If we want to have “Mac OS-like” experience, we can use Synapse Indicator which is similar to Spotlight from OS provided by Apple.


Synapse Indicator (AKA indicator-synapse) can be installed with the following commands:

sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install indicator-synapse

Drawback of Synapse Indicator is the fact that it does not have shortcut for search. We can set it by doing some “hack” described at Nerd Answer page.

Adding keyboard shortcut for Synapse Indicator (hack)

Step 1: Install xdtool.

sudo apt-get install xdotool

Step 2: Move your mouse over the synapse icon and get mouse location

xdotool getmouselocation

You should get output like this:

x:1568 y:9 screen:0 window:62914568

Step 3: Add keyboard shortcut for indicator

Go to System Settings -> Keyboard -> Shortcuts -> Custom Shortcuts.

Click add and for the command type (replace x and y with the ones from the previous command):

xdotool mousemove <x> <y> click 1 mousemove restore

Then add the shortcut you want.

It’s not pretty and elegant way, but I don’t know any other solution. If you know, how to do it better, leave a comment, below this article.

Additional note

Please remember that if you change your screen resolution or switch between two screens (e.g. laptop screen and external, bigger screen), your mouse click coordinates will have to be updated in the shortcut.

How to switch Java version on Linux?

2014-11-02 Java, Linux No comments

Sometimes we need to run specific program with a concrete version of JVM. We can also work with Java 7, but we want to try Java 8. In such cases, we can have installed both Java 7 and 8 on our system and easily switch between them.

In order to show current java version, we can simply type: java -version in terminal.
On my computer I received the following response:

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

We can see that I am using Java 8. If we want to switch to Java 7, we can use the following command:
sudo update-alternatives --config java

I am using Polish lanugage version of Ubuntu, so I received response, which you can see below.
If you are using another language version, you will see messages in your language.

Są 3 dostępne alternatywy dla java (dostarczające /usr/bin/java).

  Wybór       Ścieżka                                       Priorytet  Status
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java          1075      tryb auto
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      tryb ręczny
  2            /usr/lib/jvm/java-7-oracle/jre/bin/java          1074      tryb ręczny
* 3            /usr/lib/jvm/java-8-oracle/jre/bin/java          1075      tryb ręczny

Proszę wcisnąć Enter, aby pozostawić bieżący wybór[*]; albo wpisać wybrany numer:

Basically, we can just type number of a concrete version of JVM and press Enter. Currently, I have Oracle Java 7, Oracle Java 8 and Open JDK 7 installed in the system. When we type 2, we will switch to Java 7. After that, when we type: java -version, we will see the following message:

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)

If we want to switch back to Java 8, we can do it in the same way.

Indicators for Ubuntu

2014-09-07 Linux, Ubuntu No comments

I recently found an article about Best Useful Indicators Collection for Ubuntu. Indicators are very useful feature of the Ubuntu and Unity. Ubuntu has some default indicators, but we can add new indicators if we want to. Mentioned article contains list of many indicators, but personally I prefer and use only a few of them.

Here are my favorites:


Multi Load indicator

Nice thing. This indicator monitors system resources. E.g. usage of the processor, RAM, disk and network. We can customize it and set refresh interval. I found default low interval like 500 ms very disturbing, so I changed it to 5000 ms and it’s ok for me. In the screenshot above, you can see blue chart for CPU usage, green chart for RAM usage and yellow chart for network usage. You can change, configure and customize it as you want.

Indicator can be installed by the following terminal commands:
sudo add-apt-repository ppa:indicator-multiload/stable-daily
sudo apt-get update
sudo apt-get install indicator-multiload

System Monitor indicator

Useful indicator, which allows you to monitor temperature of your hardware components. It can monitor only those components, which have appropriate sensors. In my case I can monitor only CPU, but it is possible to monitor temperature of some GPUs and disks. If you don’t want to overheat your processor, you should use such indicator. Of course, check specifications of your processor, its maximum and common temperature. Sometimes, it’s necessary to clean computer inside or buy cooling stand in order to decrease CPU temperature.

Indicator can be installed by the following terminal commands:
sudo add-apt-repository ppa:noobslab/indicators
sudo apt-get update
sudo apt-get install indicator-sysmonitor

Indicator Sensors

Indicator Sensors allows you to display temperature of your hardware sensors like CPU. In addition, you can set an alarm for situation where temperature of your hardware will exceed given value.

Indicator can be installed by the following terminal commands:
sudo add-apt-repository ppa:alexmurray/indicator-sensors
sudo apt-get update
sudo apt-get install indicator-sensors

My Weather indicator

Indicator, which allows you to monitor current state of the weather. It can also display weather forecast for your city and display very detailed information about weather conditions.

Indicator can be installed by the following terminal commands:
sudo add-apt-repository ppa:atareao/atareao
sudo apt-get update
sudo apt-get install my-weather-indicator