Posts Tagged ‘SSH’

Tutorial Series: Linux Command Line Basics

Last week, I published a seven part series of posts introducing some of the key concepts, commands and techniques of the Linux/Unix command line. Here’s an index of the topics covered to help you find what you’re after.


Linux Command Line Basics Part VII: Tunnelling Using SSH

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. In this final part of my guide to the basics of command line Linux I’ll show you how to tunnel an internet connection using SSH.

SSH Tunnelling

Tunnelling an internet connection using SSH has many uses – if you’re on a restricted network at school or work you might not have access to certain sites. By tunnelling to a remote machine you can bypass these restrictions, allowing access to any site. The reverse is also true – by tunnelling into a machine at school or work you can gain access to resources on its local network which might not ordinarily be available to external connections.

Opening the Connection

The link established between the local and remote machines is akin to using a proxy server – we’re going to tell the browser (Firefox) to route data through a port on the local machine which is forwarded a specified port on the remote server. Requests will be made by the remote server and the results forwarded back to your local computer.

You need to choose a port which isn’t reserved for a common service – usually a high number in the port range (in the screenshot below I’m using port 9999).

Opening the tunnel to the remote machine

The command line SSH options are:

$ ssh -C username@remotemachine -D [port number]

Using this method will open a remote Terminal session also – there are options to simply open the connection and return the command line immediately, but this way you won’t forget about your connection, and it’s easier to close it when you’re done (just exit the SSH session).

Now that the port is open for business we need to instruct the browser to use it. Launch Firefox and open the preferences window. Click the ‘Advanced’ tab & select ‘Network’.

Click ‘Settings…’ to open the connection options dialog box. Select ‘Manual proxy configuration’ in this dialog box.

Now set the ‘SOCKS Host’ to ‘localhost’ and the port to 9999, or whatever port you selected when you opened the SSH session. Your config page should look something like the screenshot below:

We’re done, so save the changes you’ve made and exit the Preferences window. One way you can test whether your connection is working is to visit an IP/location site such as and see where it places you on a map.

To end the connection, simply exit the SSH session as you would normally. Remember to change back the settings you altered in Firefox, or it won’t be able to access the internet.

And that concludes my crash course in *nix command line – we started learning about the file system and are very quickly forwarding connections, using remote GUI applications using X and more. Hopefully this has demonstrated just how powerful the command line interface can be, and by taking just a little time to become better acquainted you can start accomplishing some really cool stuff. Thanks for reading!

For a full list of topics covered in this tutorial series, head over to the index page.

Linux Command Line Basics Part VI: X Window System

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. In the previous section of this guide we set up an SSH connection so we could operate a machine remotely. Now it’s time to extend this functionality using the X Window System to provide some remote GUI action to augment the remote CLI access we set up previously.

The X Window System

The X windowing system has been around for the best part of three decades and provides facility for displaying graphical content on a remote computer. Whilst a proficient command line user can perform advanced operations using only text input, some things are undeniably easier using a GUI. By using X, a remote user can wield the power of the command line alongside GUI programs, a formidable combo for a productive user.

One of the best parts of X is how simple it is to add this functionality to your remote session. The only change required from the SSH setup introduced in the previous section is the addition of  ‘-X’ to the beginning or end of the arguments. For example, if user ‘randymarsh’ wants to connect to the remote server ‘’ with X, he would enter:

$ ssh -X randymarsh@

Make sure you use a capital X! (more…)

Linux Command Line Basics Part V: Remote Access 101

Knowing basic *nix terminal commands is an absolute must for any computer pro. Whether you use Windows, Mac OS or Linux, you’re bound to face the command prompt at some stage, so here’s my crash course in CLI. The final sections of the guide will introduce a couple of slightly more advanced concepts which will help you get the most out of your command line experience.

Remote Access 101


When you open a Terminal window on your Linux or Mac computer, you’re interacting with the operating system through an interface known as a ‘shell’. The Terminal you just opened interfaces with your local computer, but using a protocol called ‘SSH’ you can control a remote computer using the same Terminal interface. (SSH stands for ‘Secure Shell’, owing to its increased level of security over its predecessors.)

SSH allows you to open a Terminal session (a shell) on your local machine which interacts with a remote computer. This is most commonly used in server administration or any computer which runs ‘headless’ (without a monitor).

Having a few SSH tricks in your toolbox is very useful indeed, and later on I’ll show you how to bypass network restrictions and use remote GUI applications as well, but first we need to get connected.


Taking SSH further with X

Over the last couple of weeks, I’ve been introduced to GNU Octave, a high-level interface to FORTRAN, with some audio functions built in. One of the major components of the work I’ve been set using Octave has been using it’s plotting functions – essentially displaying waveforms on the screen using the additional GNUplot package.

One of the problems that Octave presented pretty quickly was that it is very tricky to get working under Mac OS X (the Windows port, bizarrely, proved slightly easier for most people I spoke to get up and running). Running Octave itself is simple enough, however installing the essential additional packages required various different software packages, such as AquaTerm and GNUplot, to be loaded and configured correctly.

Under Linux, however, acquiring the software and its additional packages is done through apt-get or aptitude. Configuration is automatic.

Running Octave through SSH on my server works perfectly – it’s easy to install, and the lack of sound isn’t even a problem thanks to the ‘ausave’ command (akin to ‘bouncing’ the specified waveform), with Dropbox pushing the resulting file to the local machine for playback. The only problem I was having was with the plotting component – graphs are a step too far for the command line. The only option I had was to run Octave on my Ubuntu PowerBook.

However, I was introduced to a fantastic alternative, in the form of SSH and the ‘xeyes’ program. Using an ‘-X’ switch in the regular SSH command enables the forwarding of X-window data to the client machine. (You can run ‘xeyes’ at the server command line to check that the connection has been established). Now, commands are issued to GNUplot on the remote machine, and the data is displayed on the client (using a Macintosh, you will need X11 for this to work).

I’m excited for the potential of this technique, given the number of X compatible GUIs for command-line tools this could likely be a very useful tool.