Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.