Results 1 to 8 of 8

Thread: Run remote X applications over network using ssh

  1. #1
    Is that all you got? rockdalinux's Avatar
    Join Date
    May 2005
    Location
    Planet Vegeta
    Posts
    987
    Thanks
    27
    Thanked 71 Times in 62 Posts
    Rep Power
    19

    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.
    What's wrong? I hope I am not making you uncomfortable...

    Never send a boy to do a mans job.

  2. #2
    Administrator
    Join Date
    Jan 1970
    Posts
    40
    Thanks
    0
    Thanked 5 Times in 1 Post
    Rep Power
    10

    Default

    gr8 works

  3. #3
    Member
    Join Date
    Jan 2005
    Location
    Pune, India.
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Hey Buddy,

    You can also try ssh -Y to achive the same!
    I normally use -Y with ssh when I need a display.

  4. #4
    Senior Member monk's Avatar
    Join Date
    Jan 2005
    Location
    Tibet
    Posts
    643
    Thanks
    5
    Thanked 43 Times in 38 Posts
    Rep Power
    15

    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.

  5. #5
    Junior Member
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    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

  6. #6
    Junior Member
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Folks,

    I've been following this tutorial to get it to work without any success. I've two computers:

    hp laptop with ip addr: 192.168.0.192
    dell laptop with ip addr: 192.168.0.187

    I want to be able to show the screen of hp on dell.

    Both are running ubuntu 9.10 and X11 port forwarding is enabled for ssh on both.

    On dell I executed 'xhost 192.168.0.192'

    On hp I executed 'export DISPLAY=192.168.0.187:0 xeyes &'
    and it display the pid# on hp ( [1] 1933 ) but nothing on dell.

    I also tried the ssh -x commands that this tutorial later discusses but I get the "cannot connect port 6000 connection refused" error message.

    Any help will be greatly appreciated. We are trying to demo our gui program by displaying our screen to a remote machine using secure shell. Thanks!
    then I do a:
    ssh -X user1@192.168.0.187 gedit

    I expect to

  7. #7
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,500
    Thanks
    17
    Thanked 789 Times in 507 Posts
    Rep Power
    10

    Default

    Open terminal at dell. Type the following command
    Code:
    ssh -X username@192.168.0.192 
    xeyes &
    Make sure the following exists in hp /etc/ssh/sshd_config file. If not add it and reload sshd
    Code:
    X11Forwarding yes
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  8. #8
    Junior Member
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default

    Hello,
    A small note on X-forwarding. I'm a Solaris admin and use this everyday.
    In the /etc/ssh/sshd_config file, the line X11 Forwarding yes only applies if you are doing a ssh -X. If you are doing a export DISPLAY then it will not matter what that line says for they are not related. If you are using CSH instead of BASH you can do a setenv DISPLAY
    There are also exmples of what I'm saying on this site.
    Also if you are using ssh -x you don't need to run xhosts +All I'm saying is that it needs to be more clear that you are using them together but they are not related.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Network Diagram
    By kasimani in forum Computer Networking and Internet/broadband
    Replies: 4
    Last Post: 19th June 2008, 06:21 AM
  2. How to use two ISP in same network
    By satishap in forum Getting started tutorials
    Replies: 2
    Last Post: 24th March 2008, 09:58 PM
  3. network message
    By anharikrishna in forum Networking, Firewalls and Security
    Replies: 1
    Last Post: 6th September 2007, 03:02 PM
  4. Ubuntu: Issue accessing any System applications
    By hightech in forum Linux software
    Replies: 4
    Last Post: 29th January 2007, 09:56 AM
  5. Network Monitoring
    By puppen in forum Linux software
    Replies: 2
    Last Post: 10th May 2006, 11:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •