www.LinuxHowtos.org
Export an X Session
This tip shows you how to run GUI programs remotely by exporting an X session and tunneling it over SSH. Note that this is heavily dependant on the speed of your network connection. If you're trying to run Mozilla off of a box on the other side of the country on a 56K modem it is probably not going to work very well. The best application for this is running programs over the same LAN or possibly a high-speed WAN. An easy example application is running gvim remotely so you can have a GUI editor.
For this example we assume the local machine has an IP of 192.168.1.2 and the remote machine has an IP of 192.168.1.3. On the local machine you're going to need to give the remote machine access to connect to your X server. Use the command xhost to do this.
Code Listing 1: Local machine
// This command allows the machine with the IP 192.168.1.3 to connect
# xhost +192.168.1.3
On the remote machine, you need to export the $DISPLAY variable to your local machine. After that, you should be ready to run GUI programs remotely.
Code Listing 2: Remote machine
# export DISPLAY="192.168.1.2:0.0"
# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.
Note: This is very unsecure and not recommended since everything you type including passwords will be transmitted over the network unencrypted.
To tunnel the connection over SSH and thus encrypt the traffic edit your /etc/sshd2_config file.
Code Listing 3: /etc/sshd2_config
// Add or edit the following line
ForwardX11 yes
Now connect from the local machine to the remote machine via ssh and start your X application.
Code Listing 4: Remote machine
# gvim /etc/passwd
// You should see gvim open on your local machine with the contents
// of the remote machine's /etc/passwd file.
Notice that you don't have to set the DISPLAY variable, ssh automagically does that for you. You do however have to allow access to your local machine's X server (see above).
From http://www.gentoo.org/news/en/gwn/20030602-newsletter.xml
rate this article:
current rating: average rating: 1.5 (103 votes) (1=very good 6=terrible)
Your rating:
back