X11
If you run an X11 server on a Windows machine (Cygwin/X
or Xming
for example) then the communication is pretty straightforward as the X window system was designed to be network-transparent. The main thing that we touch is an application can be executed and displayed on different machines. You run an application locally, but specify a DISPLAY where the application is shown.
In your case the Windows box (say 192.168.1.10
) runs an application and the Linux box (say 192.168.1.11
) displays the application. In fact, the windows machine does not require to run an X server to run the application - it simply can display it on a remote Linux box:
$ DISPLAY="192.168.1.11:0" xterm
When you run the command on a Windows machine it will run xterm
locally, but display it on a remote X server which runs on a separate machine. When you run the command on a Windows machine you should see the terminal window openned on a Linux machine (remotely).
The DISPLAY
is an environment variable that holds an address and number of the current display. Every X application looks into this variable to know where to render itself. The important thing to understand is the xterm
(for example) does not distinguish whether it displays itself to a local X server or a remote X server. It is network transparent. For example, if you run xterm
and just say:
$ echo $DISPLAY
It will print a current DISPLAY
to which all applications display itself. By overriding this variable you tell the application to display itself somewhere else. I hope the concept is clear now.
Note that it is likely your Linux X Server rejects all incoming connections for security reason. To allow connections from your Windows box run the following command:
$ xhost +192.168.1.10
Actually this way is a bit insecure, because everybody who assigns this IP address to itself may connect to the X server.
Fortunately, there is a great and secure way. Since the X server just listen a TCP port - we can forward it to a local machine over an encrypted channel using ssh
which has this awesome feature. You will need an ssh daemon running on the Windows machine. You can use openssh
from cygwin
- it is easy, just set up the cygwin
with selecting the openssh
package and then open a terminal and run ssh-host-config
, but don't forget to set X11Forwarding yes
in sshd_config
.
Now, how it looks like. On a Linux box you run:
$ ssh -X user@192.168.1.10 xterm
And after entering the password you should see the xterm
window which is executed on a Windows machine but displayed on a Linux machine. After authorization ssh
binds to a port on a Windows machine where it listens for connections and forwards packets over the established channel to a local port on a Linux machine (usually 6000 for display 0). Then it runs the xterm
with setting DISPLAY
to the bound port allowing xterm
to display itself on a remote X server over an encrypted channel. In this case you don't need to run xhost
since the X server does not need to accept any external connections.
Now, how to run application on a Linux box and display it on a Windows box:
On a Windows machine you will need an X server (Xming
for example) and an SSH client (PuTTY
for example). First, ensure the Xming
running (there is a tray icon). Then, open PuTTY
, choose ssh
, fill login
and password
boxes, also ensure the X11 Forwarding
in SSH
settings is checked. Then just click connect
and after that it will connect to the Linux box with opening a terminal window. You can run xterm
there and it will be displayed on a local Xming
server (since it is forwarded by PuTTY
to a remote machine). Also look at this guide - there are some screenshots.
As the answer points out, a popular option is to install
cygwin
withX11
support. – tniles – 2016-06-03T17:31:54.990Hey vdmit11, please explain me a little more the last step (step 3), I use Xming X terminal but can not find it anywhere ...... – chimpaburro – 2012-11-17T23:16:18.787
I can not find the X terminal... – chimpaburro – 2012-11-17T23:30:27.527
OK All is clear now, but.. in the moment: ssh -X user@192.168.1.10 xterm (changed the ip and the user for the my) return error = xterm: not found... – chimpaburro – 2012-11-18T00:20:20.583
It is not found because it is not installed on your windows machine. You can't run a non-X application over the X protocol. You can't run explorer.exe for example, but you can install xterm or any other X application. I actually have no Windows machine right now so I can't install Xming to check what applications are there. You better to try in opposite direction: connect through ssh to a linux machine, run xterm there, but display it on the forwarded Xming. – Dmitry Vasilyanov – 2012-11-18T00:23:14.003
Ok, thank you very much I will continue my search and you gave me a way. – chimpaburro – 2012-11-18T00:42:11.747