Archive for the ‘Android’ Category

How to easily forward Firefox (PC & Android) traffic through an SSH tunnel

March 29th, 2015 No comments

Say you are travelling, or are at a neighbourhood coffee shop, using whatever unsecured WiFi network they make available. You could either:

  1. trust that no one is sniffing your web traffic, capturing passwords, e-mails, IMs, etc.
  2. trust that no one is using more sophisticated methods to trick you into thinking that you are secure (i.e. man in the middle attack)
  3. route your Internet traffic through a secure tunnel to your home PC before going out onto the web, protecting you from everyone at your current location

which would you choose?

VPNs and SSH tunnels are actually a relatively easy means for you to be more secure while browsing the Internet from potentially dangerous locations.

Making use of an SSH tunnel on your PC

There are many, many different ways for you to do this but I find using a Linux PC that is running on your home network to be the easiest.

Step 1: Install SSH Server

Configure your home Linux PC. Install ssh (and sshd if it is separate). If you are using Ubuntu this is as easy as running the following command: sudo apt-get install ssh

Step 2: Make it easy to connect

Sign up for a free dynamic DNS service like DynDNS or No-IP so that you know of a web address that always points to your home Internet connection. To do this follow the instructions at the service you choose.

Step 3: Connect to tunnel

On your laptop (that you have taken with you to the hotel or coffee shop) connect to your home PC’s ssh server. If you are on Windows you will need to get a program like PuTTY. See their documentation on how to forward ports. On Linux you can simply use the ssh command. The goal is to forward a dynamic port to the remote ssh server. For instance if you are using a Linux laptop and ssh then the command would look something like: ssh -D [dynamic port] [user]@[home server] -p [external port number – if not 22]. An example of one would be ssh -D 4096 -p 4000

Step 4: Configure browser to use SSH tunnel proxy

In your browser open the networking options window. This will allow you to tell the browser to forward all of its traffic to a proxy, which in this case, will be our dynamic port that we set up in step 3. Here is an example of my configuration for the example above.
If you don’t feel awesome enough doing the above graphically you can also browse to “about:config” (without quotes) and set the following values:

  • network.proxy.proxy_over_tls
    • true
  • network.proxy.socks
    • Change to “” with no quotes
  • network.proxy.socks_port
    • Change to the SSH Tunnel Local Port set above (4096)
  • network.proxy.socks_remote_dns
    • Change to true
    • Note: you cannot actually set this setting graphically but it is highly recommended to configure this as well!
  • network.proxy.socks_version
    • Change to 5
  • network.proxy.type
      Change to 1

Step 5: Test and use

Browse normally – you are now browsing the Internet by routing all of your traffic (in Firefox) securely through your home PC. Note that this doesn’t actually make web browsing any more secure beyond protecting you from people in your immediate vicinity (i.e. connected to the same insecure WiFi network).

What about Android?

Just like the PC you can also do it on Android even without root access. Please note that while I’m sure there are a few ways to accomplish this, the following is just one way that has worked for me. I’m also assuming that you already have an SSH server to tunnel your traffic through.

Step 1: Install SSH Tunnel

The first thing you’ll want to do is install an application that will actually create the SSH tunnel for you. One such application is the aptly named SSH Tunnel which can be found on the Google Play Store here.

Step 2: Configure SSH Tunnel

Next you’ll want to launch the application and configure it.

  • Set the Host address (either a real domain name, dynamic DNS redirector or IP address of your SSH server) and port to connect on.
  • You’ll also want to configure the User and Password / Passphrase.
  • Check the box that says Use socks proxy.
  • Configure the Local Port that you’ll connect to your tunnel on (perhaps 1984 for the paranoid?)
  • I would recommend checking Auto Reconnect as well, especially if you are on a really poor WiFi connection like at a hotel or something.
  • Finally check Enable DNS Proxy.

Step 3: Connect SSH Tunnel

To start the SSH tunnel simply check the box that says Tunnel Switch.

Step 4: Install Firefox

While you may have a preference for Google Chrome, Firefox is the browser I’m going to recommend setting up the tunnel with. Additionally this way if you do normally use Chrome you can simply leave Firefox configured to always use the SSH tunnel and only switch to it when you want the additional privacy. Firefox can be found on the Google Play store here.

Step 5: Configure Firefox to use SSH Tunnel

In order to make Firefox connect via the SSH tunnel you’ll need to modify some settings. Once you are finished the browser will only work if the SSH tunnel is connected.

  • In the Firefox address bar browse to “about:config” with no quotes.
  • In the page that loads search and modify the following values:
    • network.proxy.proxy_over_tls
      • true
    • network.proxy.socks
      • Change to “” with no quotes
    • network.proxy.socks_port
      • Change to the SSH Tunnel Local Port set above (1984?)
    • network.proxy.socks_remote_dns
      • Change to true
    • network.proxy.socks_version
      • Change to 5
    • network.proxy.type
        Change to 1

Step 6: Test and browse normally

Now that you have configured the above you should be able to browse via the tunnel. How can you check if it is working? Simply turn off the SSH Tunnel and try browsing – you should get an error message. Or if you are on a different WiFi you could try using a service to find your IP address and make sure it is different from where you are. For example if you configured Firefox to work via the SSH tunnel but left Chrome as is then visiting a site like should show different information in each browser.

This post is a complication of two posts which originally appeared on my personal website here.

I am currently running a variety of distributions, primarily Linux Mint 17.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Staying in shape with open source software

November 21st, 2011 No comments

On a good week, I consider myself an avid runner. Right now I’m training to run a 5k in the spring. Ideally, I’ll be able to get it under 20 minutes. Now, two of the keys to exercise are to set goals and to track your progress. Clearly I’ve got the first half under control, but the second half? Well, it turns out that’s where a lot of people falter, lose motivation, and ultimately fail. I’m no exception – I’ve tried running without really tracking my progress and I found that eventually I just gave up. Manually drawing routes, estimating distances, and keeping time take effort, and frankly I didn’t have the wherewithal to do it. Thankfully, modern technology has come to save the day. I use a Google Nexus S, which comes with a GPS and dozens of apps on the Android Market for tracking exercise.

Google My Tracks

Google happens to make an open source app that tracks runs (My Tracks). It supports waypoints (so you can get data on each mile or kilometre of your run), and it records your speed and altitude. All in all, it’s a very handy app and I use it regularly for my runs. The software integrates with Google accounts and lets you upload your runs to Google Maps and track statistics via their spreadsheets in Google Docs. And if you’re the sharing type, it also exports your runs through .gpx files .kml files and supports sharing through Twitter.

Main My Tracks spreadsheet

My Tracks summary statistics


i discovered Pytrainer through an entry at another blog. If you’re more inclined to keep your data offline, it might be a better solution for you. In order to use Pytrainer, you’ll have to import your .gpx files from your phone and specify the types of activities you were tracking (running, cycling, etc). In order to get the mapping to work properly, I had to install the gpsbabel package.  Once that was set up, I had the option to use either Google Maps or the Open Map Project. The program allows you to enter information about heart rate, calories, and equipment as well, but I didn’t have any of that information available. Gathered statistics are aggregated and can be examined for specified time periods, activities, and athletes.

Uploading a new run into Pytrainer

Mapping my run

Summary statistics in Pytrainer


This doesn’t technically fall into the category of open source, but I feel compelled to add it because it’s actually my preferred tracking solution. Endomondo is a website (with associated Android app) that allows you to track routes with the added benefits of calorie estimation, social integration (such as competitions and commenting/”pep-talks”), and a general smoothness in functionality that the other solutions don’t really reach. It also has a “coach” available and workout playlists, but I don’t make much use of those. Not that I have anything against the functions, but for personal safety reasons, I prefer not to run with headphones.

Endomondo workout imported from My Tracks

My choices

After testing out the programs and apps mentioned here, I’ve decided to go with My Tracks and Endomondo. I chose My Tracks because it integrates seamlessly with Google Maps and Docs (I like screwing around with spreadsheets) and because despite looking stripped down and simple, it’s actually excellent at what it does. As for Endomondo: its functions overlap considerably with My Tracks, but the social environment and the excellent website make it very appealing and easy-to-use. The main reason it won out over Pytrainer is because the app takes away any uploading – the second I’m done my workout, it’s available online.

Categories: Android, Free Software, Sasha D Tags:

Android development in Netbeans

June 24th, 2011 2 comments

So you want to do Android development but you hate Eclipse? Well fear not, there is another IDE that you can use to meet your mobile development needs. This is a quick guide, mostly for my reference later, on how to setup an Android development environment in Netbeans.

1. Download and install the Android SDK and Netbeans IDE like normal

Pretty self-explanatory just grab the installers from here and here respectively.

2. Download and install the Android plugin for Netbeans

The plugin to use is nbandroid and the easiest way to get it is to download it from right within Netbeans. First add the update xml ( to Netbeans.

Then simply install the plugin from the refreshed list of available ones.

3. Create an Android project

Just like you would create any other project in Netbeans. This will prompt you that you need to set up the location of the SDK. This can be done through the Manage Android SDK button.

Once created the project should be more or less good to go. Don’t worry if you get an error about a missing file, this file will be automatically generated for your when you build the project the first time.

4. Profit?

That’s pretty much it. Now when you click run it will build and deploy your application to the emulator just like it does in regular old Eclipse.

Originally posted on my personal website here.

I am currently running a variety of distributions, primarily Linux Mint 17.
Previously I was running KDE 4.3.3 on top of Fedora 11 (for the first experiment) and KDE 4.6.5 on top of Gentoo (for the second experiment).

Samsung Captivate SGH-i896 Meets Linux

November 7th, 2010 2 comments

Yesterday, I picked up the newly launched (in Canada) Samsung Captivate. So far, I’m extremely impressed with the device. The super amoled display is gorgeous, the touch screen is responsive, and the UI is stunning to look at and use. Coming from a Blackberry Curve 8310, this phone is like a digital orgasm.

Once I finished gushing over how awesome this phone is, I decided to try and get it to interact with my Linux Mint 9 Isadora install. For now, I just want to be able to transfer images and music to and from the device, although later on, I’d like to get a development environment set up and try my hand at writing some apps.

My first try at getting the phone to play nicely with Linux was not successful. It took me a little bit of fooling around before I could figure it out, but here goes:

  • On the phone, navigate to Settings > Applications > USB Settings and make sure that ‘Ask on Connection’ is selected
  • Plug your phone into the a USB port, and when prompted, select ‘Mass Storage’ from the dialog that appears on the phone
  • At this point, if you open up your Computer in Nautilus, you should see an icon that says something like SAMSUNG SGH-I896, but you won’t be able to interact with it in any way
  • On the phone, grab the notification bar at the top of the home screen and drag it down
  • In the notifications area, tap USB Connected, and when prompted, select Mount from the dialog
  • Back in Nautilus, the icon under Computer should now say something like SAMSUNG SGH-I896: 14GB Filesystem, and you should be able to read and write to the card

With these steps complete, I was able to interact with the phone through the file system and from within Banshee and FSpot. I’m not sure why the phone won’t allow Linux to mount its storage devices by default when in Mass Storage mode, but this little work around seems to make it behave correctly.

Drop me a line in the comments if you have any Linux/Android compatibility questions, and I’ll do my best to help you out.

On my Laptop, I am running Linux Mint 12.
On my home media server, I am running Ubuntu 12.04
Check out my profile for more information.