nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Run remote X applications over network using ssh

This is a discussion on Run remote X applications over network using ssh within the Getting started tutorials forums, part of the Linux Getting Started category; This small howto guides you to run remote X applications over network using ssh. Introduction The X windows system created ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Getting started tutorials

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 09-14-2005, 06:36 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 581
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default Run remote X applications over network using ssh

This small howto guides you to run remote X applications over network using ssh.

Introduction
The X windows system created by X consortium www.X.org
  • * It is client/server architecture.
    * X is OS independent and it is a Protocol
    * X protocol works over TCP/IP

What is X server?
X-server -> Talks with your hardware (VGA card, mouse, monitor etc) => It provides the screen (or display) and manages the resources. For more info on X Window System and X client-server model and network transparency visit http://en.wikipedia.org/wiki/X_server

X-Client -> Uses the display/screen provided by X-Server to display GUI/Application. It does not care how mouse or vga card works.

For example you can run X application from another computer. All you need is to setup correct DISPLAY variable.

Our demo setup with two computers:
debian-server
IP: 192.168.1.1

Suse-Linux (Laptop)
IP: 192.168.1.11

Now you would like to redirect output of laptop to server. Please note that X works on almost all UNIX like operating systems like FreeBSD, HP/UX, Solaris, Linux etc. So the commands remains same for all variant of UNIX OS.

1) Login to Debian Linux server
Code:
xhosts 192.168.1.11
xhost is server access control program for X server. The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server. In our example we are allowing host (192.168.1.11) to access server. All communication done using 6000 port.

2) Login to Suse-Laptop and run program on Debain Linux
Code:
export DISPLAY=192.168.1.1:0
xeyes &
The output of xeyes will be on debian server and not on the Suse. DISPLAY is variable which point out X server IP-address/hostname to redirect output.

Secure login over ssh i.e. forward X over ssh
SSH server has built in support to run X application remotely. Traffic between suse and debian system remains encrypted.

1) Make sure XForwarding option is on
Login to debian server, open /etc/ssh/sshd_config using text editor such as vi/vim:
Code:
vi /etc/ssh/sshd_config
2) Setup X11Forwarding to yes
Code:
X11Forwarding yes
3) Save file and restart ssh server
Code:
/etc/init.d/ssh restart
4) Allow laptop to run programs:
Code:
xhosts 192.168.1.11
5) Login from suse computer and start open office writer:
Code:
export DISPLAY=192.168.1.1:0 
ssh -X user@192.168.1.1 oowriter 
ssh -X user@192.168.1.1 xeyes
Replace user with actual user name.

This is my first small tutorial; please feel to comment back or to add your own stuff to it.
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-15-2005, 04:20 PM
Administrator
Site Admin
 
Join Date: Jan 1970
Posts: 43
Rep Power: 10
vivek has disabled reputation
Default

gr8 works
Reply With Quote
  #3 (permalink)  
Old 06-19-2006, 04:40 PM
Member
User
 
Join Date: Jan 2005
Location: Pune, India.
Posts: 47
Rep Power: 0
Ashish Pathak
Send a message via MSN to Ashish Pathak Send a message via Yahoo to Ashish Pathak
Default

Hey Buddy,

You can also try ssh -Y to achive the same!
I normally use -Y with ssh when I need a display.
Reply With Quote
  #4 (permalink)  
Old 06-19-2006, 06:42 PM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

@Ashish: Good point.

@rockdalinux: remember –Y is more secure (as it enables trusted X11 forwarding) than –X so it is best to use –X option.
Reply With Quote
  #5 (permalink)  
Old 06-23-2006, 09:33 PM
Junior Member
 
Join Date: Jun 2006
Posts: 1
Rep Power: 0
rohan208
Default

I've been looking for this, thanks.

I found adding something like this to ~/.bashrc very useful..

Code:
if [ "$SSH_CLIENT" != "" ]; then
    export DISPLAY=`echo $DISPLAY| cut -d\  -f1| cut -d: \f4`:0
fi

..R
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Network Diagram kasimani Computer Networking and Internet/broadband 4 06-19-2008 07:21 AM
How to use two ISP in same network satishap Getting started tutorials 2 03-24-2008 10:58 PM
network message anharikrishna Networking, Firewalls and Security 1 09-06-2007 04:02 PM
Ubuntu: Issue accessing any System applications hightech Linux software 4 01-29-2007 10:56 AM
Network Monitoring puppen Linux software 2 05-11-2006 12:01 AM


All times are GMT +5.5. The time now is 03:30 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36