Changes

Jump to: navigation, search

Remote X

4,193 bytes added, 22:33, 1 December 2015
Created page with 'The X Window System is a client-server graphics system: * the '''server''' manages the display hardware, each typically including one or more video cards and monitors, one or mor…'
The X Window System is a client-server graphics system:
* the '''server''' manages the display hardware, each typically including one or more video cards and monitors, one or more keyboards, and one or more mice or other pointing devices.
* the '''client''' software connects to the server through one of several network transports to draw on the display, get status information, and receive input from the keyboard and mouse.

In a typical Linux system, the server and clients run on the same computer, although one or more clients may also be remotely connected.

== Displayspecs ==

X servers are identified by a display specification or ''displayspec'': <code><nowiki>[server]:display[.screen]</nowiki></code>

Where:

* ''server'' is the hostname of the server: blank for local connections via the fastest avilable means; <code>localhost</code> for local connections via TCP/IP; or a hostname for remote connections via TCP/IP.
* ''display'' is the display number. These are numbered starting at zero. The port number used for TCP/IP connections is (6000+''display'').
* ''screen'' is the screen number if the display supports multiple screens (this is mostly obsolete; most multi-screen X servers now merge them into a single display, using the ''Xinerama'' protocol extension).

Therefore:
* the default local display number is <code>:0</code>
* display 0 on the host <code>red.example.com</code> is <code>red.example.com:0</code>

Displayspecs are communicated to client programs through the DISPLAY environment variable (or, less often, through command-line arguments).

== Remote Access to an X Server with SSH ==

To run a client in a remote location from the server, you can run the raw X protocol over tcp/ip or other network transports. However, this is very insecure and is not recommended. Instead, current best practice is to use an ssh session to tunnel the X traffic.

Most standard ssh clients can set up the tunnel, X authentication, and other details necessary by simply including the -X or -Y command line parameters.

In these examples:
* ''red'' is the local computer, running an X server
* ''blue'' is the remote computer on which the client program will be run
* ''user'' is the name of the user on ''blue''

To connect to ''blue'' and start a shell, from which any program may be run:

ssh -XC ''user''@''blue''

The <code>-X</code> argument sets up the X tunnel, while the <code>-C</code> argument turns on data compression for improved performance.

To connect to ''blue'' and start the program ''gnome-calculator'':

ssh -XC ''user''@''blue'' ''gnome-calculator''

== Using VNC ==

VNC is a remote display software that originated at Olivetti Research Labs in Cambridge UK. It is cross-platform and very lightweight. The underlying protocol is called ''rfb'' (for ''remote frame buffer''). There are many different software packages that support various aspects of the vnc/rfb system.

When used with the X Window System, it is necessary to have a dual server that functions as both an X server and a VNC server. The easiest way to do this is to run the <code>vncserver</code> script from the <code>tigervnc-server</code> package, which configures and then start the <code>Xvnc</code> server. To connect X client, set and export the <code>DISPLAY</code> environment variable; to connect a VNC client, use this command: <code>vncviewer -via ''blue'' localhost:''display''</code>

== Using Xvfb ==

<code>Xvfb<code> is a dummy X server that does not display output on any device. This is useful where a program needs to connect to an X server, perhaps for testing purposes, but the actual image drawn does not have to be viewed anywhere. Xvnb would typically be invoked with a command such as:

Xvfb :0 -ac

Where <code>:0</code> is the display number and <code>-ac</code> disables access control to allow any local client to connect. You can then connect a client by setting and exporting the <code>DISPLAY</code> variable and starting the client:

export DISPLAY=:0
gnome-calculator

== Resources ==

* '''X Power Tools''', a book by [[User:Chris Tyler|Chris Tyler]] published by O'Reilly Media and available through the Seneca Libraries on-line services.

Navigation menu