Linux-Tip News

We are proud to present Linux-Tip Europe. This page is designed to provide the Linux users community (not only in Europe) with news and articles that are of interest to them. It works by allowing members of the community to submit news and articles relating to Linux hardware and software. This same community can then decide what tips should be promoted based on what they consider to be the most important or interesting to the community by voting stories up and down. Stories that receive enough votes are promoted to the Linux-Tip Europe homepage. Bookmark and Share
 
Home arrow Workshops arrow Workstation arrow X11 Forwarding using SSH
X11 Forwarding using SSH Print E-mail
Wednesday, 06 June 2007
As I have explained earlier, there are different ways to connect to remote servers or workstations. You can use NoMachine’s NX server or the GPL solution called  FreeNX. Other tools like RealVNC or VNC provide remote control software which lets you see and interact with desktop applications across the network.

One way to enforce the traffic security is to use the SSH by the way of X11 tunneling or port forwarding. SSH was developed  to replace the insecure telnet, ftp,  rcp, rlogin, rsh software. FreeNX is already perfectly using this technology. In this article I will show, how to forward X11 using ssh without any additional software on the Linux site. Additionally I will explain how to run Linux applications on Windows XP clients using PuTTY and X-Deep/32.

For instructive purposes, we will use a small scenario to explain what needs to be done. There are two machines we would like to access remotely:

  • OpenSuse 10.2 running KDE
  • Debian 4.0 running Gnome

As client machines we will use OpenSuse with client ssh software but also Windows XP with Putty. From the perspective of SSH, the remote machine is the server and your local machine is the client. The workshop setup could look like this:


 


Step 1: Preparing the ssh server

First, you must have your SSH package installed on the server. We will use the  OpenSSH packages provided by the distribution. Please verify  how to find and to install rpm packages in both distributions. In some cases it is already installed on the server (some installed it as standard packages).
If you build the software from source, make sure to compile it with X forwarding support. The binary packages contain runtime X detection in SSH version 3.2 and above.
 

 

 


Also, make sure that you have the following line in your /etc/ssh2/sshd2_config file:

AllowX11Forwarding              yes

That’s it already!  Start the sshd using one of the following commands: 

 

/etc/init.d/sshd start
service sshd start
 


Step 2:  Using a Linux client

You may have noticed that Linux is using virtual consoles by using the Ctrl-Alt-F1(-F12) key combinations. Generally, there's no reason to leave the default console (virtual console #7) unless you are attempting to login again or to diagnose  problems.

Please switch for test purposes to other consoles like this:

Ctrl-Alt-F2  -   to a new shell prompt
Ctrl-Alt-F12  - to a empty console
Ctrl-Alt-F7   -  back to the X graphical display

As you have seen while using the keystroke Ctrl-Alt-F12, there is nothing really running on this console. Let’s display the remote machine GUI here. We can later easily switch from your client to the remote machine using the appropriate key combinations. 

Login to your  client machine,  run KDE and open a console as a normal user (no root permissions needed). We will open a X session on console 12 using the following command:

X :12.0 vt12 2>&1 >/dev/null &

 

 

 
This will send all unneeded output the bit bucket or black whole but will open another X window on console 12. If you now switch to it by using the Ctrl-Alt-F12  keystroke, you will see something like this (empty grey background):

 

 


Change back to you original graphical display using Ctrl-Alt-F7. Go back to the console you have used before and create a ssh connection to the remote server using the following command:

 

xterm –display :12.0 –e ssh –X This e-mail address is being protected from spam bots, you need JavaScript enabled to view it &

 


 

“User” should be a valid user on the remote system and you can (certainly) replace the IP address by a valid domain name of the server.

If you now switch back to console 12 (Ctrl-Alt-F12), you are getting a prompt after typing the correct password. This could look like this:

 

 

Start KDE on the OpenSuse remote machine simply by using the command

kde
 

 

 

If you like to access the Debian machine instead, you have to use the following command:

xterm –display :12.0 –e ssh –X This e-mail address is being protected from spam bots, you need JavaScript enabled to view it &
 
Start Gnome on the Debian remote machine  by using the following command
 

gnome-session &

 

 

 

 

Please notice that in both cases a  x-term window with logging information appears. You can minimize it  but shouldn’t close it.
If you like to cancel the connection, simply close the xterm window or use the “more direct” way by using the Ctrl-Alt-Backspace keystroke.
As I already mentioned before, you can now work on both machines and switch it by using the  Ctrl-Alt-F7  and Ctrl-Alt-F12 key combination. 

 

Step 3:  Using a Windows client

Unfortunately we have to use additional software on the Windows site to get it running. 
We will use Putty to connect from the Windows XP client to the remote server. PuTTY is a free implementation of Telnet and SSH for Win32 and Unix platforms, along with an xterm terminal emulator. It is written and maintained primarily by Simon Tatham.
If you like to use the X11 forwarding feature, you will need an X display server for your Windows machine, such as Cygwin/X, X-Win32, Exceed or  X-Deep/32. This will probably install itself as display number 0 on your local machine; if it doesn't, the manual for the X server should tell you what it does do.
We will use in this workshop X-Deep/32 as the X display server. Please download and install the software first. You will find a download link, detailed instructions and additional help on this webpage.

 

 


Open up the command putty.exe by double-click it. It will open the interface. First, setup the connection info in Host Name (or use IP) field and select SSH (using port 22). In the field “Connection Category”, find the Connection tree. In SSH, expand it and you will see Tunnels window. Click "Enable X11 forwarding". It is setting the default to X display at "localhost:0". Now, go back to Session and save this session with a name you like. I’m  normally using the IP address of the server.

 

 

 
With the X-Server running in the background, you should now be able to run X11 applications.  In the next image you can see Linux application like xclock and konqueror running on a Windows XP desktop.



 

 


 

 

 



 
< Prev   Next >

Bookmark this article

Virus Info Feed

Alexa Traffic Stats

Sedo - Domains kaufen und verkaufen das Projekt linux-tip.eu steht zum Verkauf Besucherstatistiken von linux-tip.eu etracker® Web-Controlling statt Logfile-Analyse
Urlaub Spanien