
SSH is a great tool to get around your computers with. There are lots of things you can do with it besideds simply connecting to another machine. Did you know you could use X11 forwarding to get graphical programs running on one machine to display on another? This guide will help you with that and a few other neat things, such as using compression, encryption and using SSH to install cable television and set the time on your VCR. Okay, so it’s not that flexible – let’s see what we can do.
This tutorial is written on an Ubuntu box, using these tools. It will work fine in Debianland but you’ll need to change some terms for it to work line for line in other Linux distros. This tutorial will cover some basics and then get a tad more advanced.
First, you’ll need SSH installed on your machines. Most distros come with the client, but you’ll need a server on the machine you’re connecting too. Either use Synaptic to install openSSH or type the following in a CLI:
sudo apt-get install openssh
Now that we have an ssh server on our machines, let’s hurry back to our desktop/laptop and give this thing a whirl.
In this example, I’ll use two machines. My laptop, called Butter and my desktop, called Knife.
So, from butter I type:
ssh arsgeek@knife.some.domain
Replace ‘knife.some.domain’ with the system you’re sshing too and replace arsgeek with your username on that computer. Now you’re got a CLI connection to that computer and you can do stuff on there. Awesome! Let’s dig in to SSH a bit more.
Let’s say you want to run a graphical application from a remote machine (in this case Knife) and display it on your local machine (Butter). It’s not hard at all.
ssh -X arsgeek@knife.some.domain
From there, if I want to launch gFTP from Knife and see it on Butter, I simply type gftp and poof! The gFTP window pops up on my laptop.
Now your ssh client can also look for options in a file in your home directory. This file probably doesn’t exist yet, so let’s make it and I’ll show you a few things that it can do.
gedit ~/.ssh/config
Now you can put this in your config file to automatically do X11 forwarding when you log into a machine:
ForwardX11 yes
Neat eh? You can also get a bit more granular. Say you have two machines, one of which you don’t want X11 forwarding for (perhaps it’s not set up to do it). You can specify machines in your config file with the Host entry:
Host knife.some.domain
ForwardX11 yes
Host spork.some.domain
ForwardX11 no
This enalbes X11 forwarding for Knife, but not Spork. There’s a whole host of options you can put in your local config file. We’re not going to look at all of them here, but you can find them at this link.
If you have several different machines with multiple usersnames (say, for work, school and home) you can also specify the user in your config file. Let’s take the example above but do this with two different users. Say I log onto Knife as user arsgeek but I log onto spork as user beavis.
Host knife.some.domain
User arsgeek
ForwardX11 yes
Host spork.some.domain
User beavis
ForwardX11 no
Now I don’t have to type ssh username@hostname each time I want to connect to these hosts. I simply type ssh knife.some.domain and my config file worries about the user and X11 forwarding.
Another great option to use is KeepAlive. This will tell the session to make sure your connection stays connected and to also listen for outtages. Should your network go down, it will automatically kill your session for you. This isn’t so hot on a dial-up line though as it may cause excess online time. Your options with this are either yes or no, so add it like this:
KeepAlive yes
You can also specify domains, or options for any (other) hosts. For instance, if both Knife and Spork are on the arsgeek.com domain and I want the same options for them I can say:
Host *arsgeek.com
Or if I want options for all hosts to apply, I can use:
Host *
Order is important for your config file. For instance, this config file would allow X11 forwarding for only things on the arsgeek.com domain, I’d do this:
Host *arsgeek.com
ForwardX11 yes
Host *
KeepAlive yes
Now I’ve got X11 forwarding from arsgeek.com machines, and everything is using KeepAlive.
If you have a slower connection then a good speed trick is to enable compression. You can do this by either typing ssh -C hostname or adding this to your config file:
Compression yes
SSH has 9 compression levels, with 1 being the fastest and 9 being the slowest but most compressed. It will default to 6 but you can change this in your config file with this entry:
Compressionlevel 8
Change the ‘8‘ to whatever you want.
You can also use SSH to run commands on remote machines and display output back to you. If I want to see who’s on Knife I could enter the following command:
ssh arsgeek@knife.some.domain who
I’ll still be prompted for my password, but once I put it in, I’ll get the output of the who command as it is run on knife. The SSH session with then terminate.
Now SSH is great for sitting at your laptop or desktop, but what if you fly to Uzbekistan and you’re at a public terminal in an internet cafe and you suddenly remember you have to SSH into your work computer to do something-or-other? Well you could possibly download a program like Putty, but many public computers won’t allow you to install or download programs. How about this, grab a web enabled java SSH client, put it on your website and simply user any browser to get there!
That’s where this amazing little program MindTerm comes in! You can download this java application, and then put it on your website. Once it’s on a website you can use any java enabled web browser to get to that site, then use this nifty little app to SSH to where you need to go! To test it out, download it to your desktop and run the mindterm.jar file. Configuration information is also included in the download.
That’s all for this SSH tutorial. There’s a lot more to learn about SSH and you can find great resources on the web, or as always by typing ‘man ssh‘.
geek out.
Popularity: 4% [?]












July 16th, 2007 at 2:35 pm
This is not Ubuntu/Debian specific it’s just what ssh does.. on any machine and between any machines.
Some crippled operative systems (such as windows, any flavor) might need you to install an ssh implementation, but otherwise ..
August 27th, 2007 at 6:00 am
i need your help for configuring ssh on my system.
August 27th, 2007 at 6:03 am
i need a step by step simple complete process of configuring ssh in my system.
i am using ubuntu 7.04 operating system.
August 27th, 2007 at 8:26 am
Pramod,
SSH is already installed in 7.04. To install the server, simply type:
sudo apt-get install sshd
For info on how to configure it type ‘man ssh’
June 22nd, 2008 at 2:55 pm
hello,
im syam from malaysia. i need some help for changing coding for DNS server.
use bind and putty configuration.
for ubuntu linux.
im da new user for linux.
can u help me?
please teach me step by step.
my english not very well.
thank you.
November 30th, 2008 at 2:01 am
i love your site, hope you love mine 2005 new year :]
July 14th, 2010 at 4:38 am
HAHAHAHAHA you are funny, using a poster from Soviet Union for Ubuntu, actually it was drawn during the WW 2, and it was concerning spies.