LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-24-2011, 01:50 PM   #1
hyperutila
LQ Newbie
 
Registered: Jan 2011
Posts: 5

Rep: Reputation: 0
Remotely open an application


Mostly out of curiosity, I'm wondering if it's possible to open an application remotely from the terminal. Here's what I mean by that: I know that you can set up X forwarding through ssh like this:

Code:
ssh -X name@host
But that will make it so that the application opens on the remote computer. Instead, I want to be able to ssh into a computer, type a command, and have an application open on the host computer, not necessarily visible to the person who logged in remotely and issued the command. Does that make sense? Is that possible?
 
Old 01-24-2011, 02:49 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Just set the DISPLAY variable to the host local display when executing the command. For example:

Code:
ssh -X name@host
DISPLAY=:0.0 somecommand
 
Old 01-24-2011, 04:17 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,597

Rep: Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690Reputation: 2690
Display=:0.0

The above assumes that you want to open a X-Windows gui program (such as oclock or xterm) and that the :0.0 desktop exists. Non-x program may be started, and will run if they need no tty attached.
 
Old 01-24-2011, 06:21 PM   #4
wilyumdg
LQ Newbie
 
Registered: Mar 2005
Distribution: CentOS/SuSe/Ubuntu
Posts: 2

Rep: Reputation: 1
I think I understand what it is you want to do but let me put it into words.

You want to ssh from workstation A to host B and run a command (like xterm) which then displays on workstation C. Is that correct?

You must understand a little about X and the client/server relationship to see how this works. In X terminology both of the workstations in question, A and C are considered to be servers and the the program which you run on B is the client. Using the command in your post really just does some nice things in the background to set up this relationship (between your workstation A and the server B).

Manually you can also do it this way. You need to know the IP address of your workstation A, lets say it is 192.168.0.3 and your workstation must be running X windows or an X windows emulator on a Windows host.

1. log on to B (lets say 192.168.0.2)from A (192.168.0.3)
$ ssh 192.168.0.2
2. Set a DISPLAY environmental variable on B
$ export DISPLAY=192.168.0.3:0.0 # This essentially points the DISPLAY for any x window clients to the x window server running at
# 192.168.0.3 on its primary display 0.0
3. Run an x windows client (ie xterm)
$ xterm & # the clients can be run in background which is why the "&" is used

Now if everything works the "window" from the xterm will show up on your display on workstation A.

However, there is no reason that you cannot put a different ip address in the DISPLAY variable.


1. Change the DISPLAY setting on the same session as above

2. Set DISPLAY a different workstation
$ export DISPLAY=192.168.0.4:0.0 # point the DISPLAY to workstation C
3. Run an x windows client (ie xterm again)
$ xterm &

Now if everything works the "window" from the xterm will display on workstation C

Several years age this all would have just worked this way and we often played games with each other by running something on a local host but putting its DISPLAY on a co-worker's workstation. But actually now this is not so easy anymore.

A lot of people consider that running x windows wide open so that it accepts connections from any client (like the xterm above) is a bad idea and so these days most distributions lock down the x windows configurations pretty tightly. In this case you will get an error when you try to run the xterm client which says that it was unable to connect to the x windows servers at the ip address you specified:

xterm Xt error: Can't open the display 192.168.0.3:0.0

In general then you need to do the following:

1. Change the configuration in your workstation's x windows config to allow connections from remote clients. In some distributions there will be a GUI configuration tools and you should look for a security option which indicates that you want to allow connections from a remote client. Since most distributions consider this to be a security risk it is getting harder and harder to find a way to do this in the GUI. In that case you will need to dig into the x windows config files which is somewhat daunting and beyond the scope of my comments here.

2. You will need to restart x windows (it may be simplier to just reboot)

3. Now your x windows will allow a connection; now you need to authorize the host B to use your x windows server
xhosts +192.168.0.2 # in this case you are allowing B (at 192.168.0.2) to use your display

4 Now you can follow the steps above.

In order for this to work on a third workstation you will need to make the same chages on it as you made above on your own workstation.

As you can see, with the advent of stricter controls on x windows, this has gotten much harder. This is the primary reason that most people use the tunneling capability which is built into ssh to do this sort of thing. But despite this, it is still possible to do what you would like to do (that is, if I really understood what it is that you are trying to do.... ;-) )

Now the real question becomes, is this a wise thing to do? Only you can decide that in your own environment but you should at least be aware that most people consider opening up access to the display within x windows to be a security breach.
 
1 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to open an user account remotely [SOLVED] Fabio Paolini Linux - Desktop 5 02-03-2010 04:14 PM
Running X Application remotely arivupp Linux - General 3 05-08-2009 07:25 AM
Redhat4 : How to access remotely and use graphical application? shong9 Linux - Newbie 3 10-18-2007 03:39 PM
Redhat4 : How to access remotely and use graphical application? shong9 Linux - Software 1 10-18-2007 02:06 PM
starting X application remotely spidy_123 Linux - Networking 2 10-19-2005 05:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 01:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration