Friday, August 14, 2009

Importing a remote desktop session via ssh tunnel

At home I have, 2 machines, one running Ubuntu 9.04 (Jaunty) and the other running Ubuntu 8.04 (Hardy). The Hardy machine is used by my family members and I use Jaunty for my experiments. Some times, I would like to test some thing on Hardy also. But most of the times that machine is not free. I use ssh to login to the hardy box and use an ssh tunnel to export the GUI session back to my Jaunty box.

The steps I took are detailed below.

On Hardy box

1) Install open ssh server

$sudo apt-get install openssh-server

On Jaunty Box

2) I switch to a text terminal by pressing Control+ALT+ F2. (any thing from F1 to F6 will work)

3) Login to the text terminal

4) Start a new session on Virtual Terminal 8 and launch xterm on it.

$ xinit /usr/bin/xterm -- :1

( :1 above represents the virtual graphical display , you can also use :2 )

5) A gray screen with xterm will appear on virtual terminal 8. If it is not appearing you can switch to it by

$ chvt 8

Or by pressing Control+Alt+f8

6) Now ssh to the Hardy box with tunneling.

$ ssh -Y fermi@192.168.0.2

Give your credentials and login (The IP address above is that of my Hardy box, you can replace it with your user name and IP). You are now logged to Hardy. The GUI of any program launched on Hardy ( in this terminal) will be tunneled back to Jaunty via ssh.

7) Start a gnome session on Hardy by typing the following command in the xterm terminal.

$ gnome-session

You can start other desktop sessions like kde or xfce , if they are installed.

6 comments:

Anonymous said...

I use something like the following command on Fedora for Gnome:

$ DISPLAY=:8 ssh -CXYf fermi@192.168.0.2 gnome-session

Or for KDE:

$ DISPLAY=:8 ssh -CXYf fermi@192.168.0.2 startkde

Note that due to the -f option to SSH, the tunnel would automatically fall into the background once connected.

The option -C is good for SSH because it includes compression.

Azerthoth said...

Using ssh -CY can be of assistance. -C allows for compression. It adds a little over head on the machines at both end but allows for a better data transfer rate.

Callum Wilson said...

I just use:
$ ssh -X -lmyloginname 192.168.0.2

from a client machine konsole. You get onto the console of the target machine - but starting X applications, such as "kmail &" route the X traffic through ssh to the client machine.

Gerard Lally said...

Thank you! This helped me so much!

Unknown said...

A reliable multi-platform-supportive remote desktop connection that I know of is RHUB http://www.rhubcom.com. RHUB’s product line also includes a 4-in-1 appliance that allows remote access, Secure Web Conferencing, remote support, and webinar, all in a single box, which means a single solution for diverse collaboration needs, and great value.

Anonymous said...

I see a lot of people having trouble making these connections through Ubuntu..it makes me wonder if there are any third party remote desktop software solutions available on this platform, and, if not, exactly how long it will take for that to cease being the case..