Using SSH as an Ad-Hoc VPN

Laptop - source http://www.sxc.hu/photo/888008

Many of us have been in this scenario - you're on the move, using a random WiFi connection that you can get. You want to browse around to all your favourite sites, including ones where you log in over normal HTTP, but you're not entirely convinced of the security of the connection, so you don't.

If you have access to pretty much any server running SSH where you can log in, you actually can set up a secure tunnel to route all of your data through using nothing more than what you already have. Kind of like a very simple VPN, that you can do on the fly.

This assumes your client/laptop is running Linux, Mac OS X or another Unix-like OS where ssh is installed and on the command line. We'll also be configuring Firefox as the browser to route traffic through the tunnel. Windows users can use PuTTY to achieve the same effect.

Set Up the Tunnel

From your terminal, log in to your SSH server with the normal command, but add -D and a port number, to set up your tunnel on that local port. Something like this:

$ ssh -D 1080 user@host

You'll be logged in as normal, and the prompt should come up. What has also happened, however, is that your SSH client is now listening on local port 1080. Anything you tunnel through there will go securely to the SSH server, and responses sent back through that tunnel.

Before we move on to configuring Firefox to route through this, here are a few more options for that command. If you don't want a prompt to come up, i.e. you just want to set up the tunnel and don't need to actually interactively log in to the server, add the -N switch, like so:

$ ssh -ND 1080 user@host

Also, you can use gzip compression to speed up the transfer. Combined with no login, that is:

$ ssh -CND 1080 user@host

Configuring Firefox

Our tunnel is now up and running, and should be accepting traffic. To configure Firefox to use this tunnel, first go to Edit > Preferences and choose the Advanced section.

Firefox Proxy configuration screenshot

Under Network, click the Settings button. Choose a Manual proxy configuration.

Under SOCKS Host, put localhost and port 1080. Leave it on SOCKS v5.

Firefox Connection Settings screenshot

Say OK to that, close Preferences and now use something like Check IP to confirm that your IP address now appears to the outside world as your SSH server's IP address. This tells you that your traffic is being tunnelled and you can now do anything you wish without fear of snooping (provided you trust your SSH server and its connection, of course).

Finishing Up

When you're back home or you've closed the SSH session, make sure to go back to that dialogue in Firefox and choose No proxy (or whatever it was set to before). Otherwise, you won't be loading any pages any time soon.

Speaking of which, when you're done, go back to that SSH session in your terminal window and hit Ctrl+C to drop the connection and close your tunnel down.

This is a really simple way to securely browse on untrusted connections and the fact that it doesn't require any special setup on the SSH server makes it particularly easy when you just happen to find a moment when you need to use it.

Quick, easy and gets the job done. You can't ask for much more than that.

[image source]

KDE Tip - Switching NumLock On at the KDE Login Screen

Back last month I covered a quick KDE tip on how to set the Num Lock key on when you log in to KDE.

While that generally works, it doesn't cover the KDE login screen (or KDM).

You might wonder why this is an issue, but I have found that on my Kubuntu Hardy system, if you don't have Num Lock on at the KDM screen, the keyboard Num Lock light will stay off when you log in to KDE. KDE will then dutifully turn Num Lock on, but the light won't go on for some reason.

This results in the confusing state of having the Num Lock light on the keyboard display the opposite to what the current Num Lock status is.

To fix this, you can set Num Lock on at the login screen, which toggles the light correctly.

Unfortunately, I can't find any way to change this setting graphically, so here's how to do it through configuration files. The file you need to edit is kdmrc.

The exact location of that file might vary according to your distribution. Here on Kubuntu it's /etc/kde3/kdm/kdmrc, but it might be in a share directory somewhere.

Try this to find it:

$ locate kdmrc

Open that file up in a text editor. You will probably need to have administrator privileges, so press Alt-F2 and type this:

kdesu kwrite /etc/kde3/kdm/kdmrc

In that file, find the first section that begins:

[X-*-Greeter]

Right after that line, add this:

NumLock=On

Save the file and quit. To see your changes, you might need to restart KDM. The easy, but slower, way to do this is to restart the computer, but you can also try pressing Ctrl-Alt-Backspace to restart the graphics server which should bring KDM back up again.

Num Lock should now be on at the login screen. Shame it had to be so complicated.

Set Up a Custom Worksheet with KSysGuard

The KDE System Guard at first glance just looks like a simple system monitor application which lets you take a look at the System Load and Processes running on your machine.

It is actually capable of a lot more monitoring than that, and if you delve deeper into it, you can customise the way it works to show you information about your system that you are interested in.

So, let's take a look at the program. You should find it under the System category of your Applications list (it might be named Performance Monitor).

KSysGuard default screen

What you have is two tabs, as I mentioned, that give you some statistics about how hard your machine is working, and the processes running on it. Along the left hand side, there's also a Sensor Browser pane. If you want, you can take a look through the available sensors to see what you can look at.

So, let's create a new tab within KSysGuard to show some additional information.

The application calls these tabs 'worksheets', and you can make a new one and drop your desired sensors onto it, to make a heads-up display for the statistical information you care about.

For this example, I'm going to create a worksheet to show me the current CPU temperature, the content of /var/log/messages (so I can see what hardware gets attached for example, or any other messages from the kernel), a network measure and my 15-minute load averages. Of course, here, you'll probably want to pick a set of sensors that you are interested in watching, these are just examples.

So first we need to make a new worksheet to put these on. Go to File and choose New Worksheet.

KSysGuard\'s File Menu screenshot

Give it a name, I'll go for Custom HUD. You also set here the number of rows and columns that this worksheet provides you. Because I have four sensors I want on this sheet, I obviously need two columns and two rows.

KSysGuard Worksheet Properties

You can also set here how frequently the data is kept updated. More frequently will mean that your monitoring will be more expensive in terms of CPU usage and will mean KSysGuard will consume more resource. I'm going to leave the default here.

Once that's done, you'll have a blank tab, or worksheet, to work with. There should be four 'Drop sensor here' labels.

Simply drag and drop sensors from the browser into these cells. Some sensors have more than one way of showing you the data, such as a graph, or just a number. When you drop them, you'll be asked which type of display to use.

Once you've got everything in place, you can now monitor what's going on. Be sure to right-click your sensors and check the Properties. Some sensors allow you to change the way they report things, so it's worth checking those settings to see if there's anything you can tweak to get it to work the way you want.

In addition, if you picked a graph view, you can often manually configure the maximum and minimum points of the graph if you want, instead of auto-detecting the max and min from the values it gets.

KSysGuard Graph Configuration Min/Max Values

Another point I should make is that if you do pick a Bar Graph style display, it is possible to then drag additional sensors onto the same graph, and plot two different sets of values for comparison. Once you've dropped them on, configure the Graph by right-clicking, and going to Sensors in Properties.

When you're happy with your layout, click the Export Worksheet button (or choose it from File). If you save into the default folder it gives you (~/.kde/share/apps/ksysguard/), it will open back up automatically next time you launch KSysGuard.

KSysGuard with a Custom HUD

And there you have it. You can now view your favourite statistics about the running of your machine from KSysGuard. What looks on the surface like a pretty basic monitoring application is actually a lot more powerful, and gives you quite a bit of flexibility. Granted, watching statistics about how your machine is running might not be the most exciting thing in the world, but if you're semi-obsessed (like me, perhaps?) or trying to troubleshoot, KSysGuard can be pretty useful.

A quick footnote for those interested - the exact locations of the sensors I used for my custom HUD are as follows:

  • ACPI > Thermal Zone > THRM > Temperature
  • logfiles > messages
  • Network > Interfaces > eth0 > Receiver > Data
  • CPU Load > Load Averages (15 mins)

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. ...
  7. Go to

Sign In

    Enjoy FOSSwire's content? Have it delivered! Subscribe