The X Protocol
In X the X client, which is the application is completely separate from the display which is the X server.
On a computer the X clients and the X server still use the X protocol but they are using it on Unix domain sockets which are faster than network sockets. Each managed display has is regulated for the number of connections in /tmp/.X11-unix/X#. There is a number after the X. You can see this with:
The “0” means that it is configured for local display only.
X clients on one computer can display another host’s X server over the network once permissions have been set up.
The X Client, WK, wants to view applications on the remote X Server, RD. The first thing that must happen is that the remote host must give permission for the X Client to access the site:
xhost + wk
This enables the user access from the X client. Now the X client accesses a program using the DISPLAY.
DISPLAY=rd:0 term &
This will display a terminal from the remote X server, rd on the X client. This of course is assuming the firewall is not blocking remote X.
Another scenario is when you have an account on the remote server, rd and you want to redirect the display back to your workstation at wk. On the remote server do the same:
xhost + wk
Now access the remote server with telnet or SSH and then run this command on the remote server:
This then displays the xterm on the client wk.
You can add access to a host by using the command:
xhost + wk
You also can remove access by using this command:
xhost – wk
One security mechanism that you can use to work with X is xauth used with the ~/.Xauthority file. Each user has this file in their home directory. This file contains MIT-MAGIC-COOKIEs—keys that can be sued to authenticate users. Xauth can manage the .Xauthorityfile with various options. The list will show the Magic Cookie.
xauth list $DISPLAY
dg/unix:0 MIT-MAGIC-COOKIE-1 474f9a9ed0672750a11c1a7dcb933975
Then you can add the cookie to the remote machine $DISPLAY with
xauth add $DISPLAY 474f9a9ed0672750a11c1a7dcb933975