As you'll see in the next few sections, the DISPLAY environment variable tells X Window system applications which device they should contact in order to display their output. In most cases, you won't have to set this variable because the default is always your local machine. However, in general, the DISPLAY environment variable is declared using a command such as the following:
DISPLAY=displayname; export DISPLAY
The displayname specification uses the following form:
When specifying a DISPLAY, hostname specifies the machine on which the display is running and must be either a machine name or the machine's network address, as listed in /etc/hosts.
The display_number variable specifies one of the displays on hostname. Each display on a system is assigned a display_number, beginning with 0. The variable screen_number specifies the screen on which the display is running. In most cases, you can specify a displayname as hostname:0. For example, you would execute the following command to display output on the host foo:
Displaying an Application Remotely
Suppose, for example, that you are logged in at the machine bible, and you log in via ssh to the machine wiley:
[email protected]:~> ssh wiley
You now try to start an xterm:
[email protected]:~> xterm xterm Xt error: Can't open display: snark:0.0
If, instead, you start out by using the -X option to ssh, everything works as expected and hoped — the DISPLAY variable is correctly set and ssh does X forwarding:
[email protected]:~> ssh -X wiley Password:
You will now see an xterm running on wiley and displaying in front of you (on the monitor attached to bible).
If you simply want to run single graphical applications remotely, this is all you need to do.
| f - - p Some systems that support SSH deactivate X11 forwarding in their SSH daemon's ' - ~ ■"■> ■ configuration files or in their X server's configuration files. If you have problems getting X11 forwarding to work, check your system and X server configuration settings.
Using the DISPLAY Environment Variable
Suppose that you are logged in at the machine bible and you check the value of the DISPLAY environment variable:
You can set that variable to point to a display on another machine and try to run a program:
Typically you will see something like the following:
xterm Xt error: Can't open display: wiley:0
If you type:
[email protected]:~> xhost access control enabled, only authorized clients can connect this shows that clients from other hosts cannot connect to the X server. You can allow clients from bible to connect to the X server with the command:
Note, however, that the capability to do this is now switched off by default in SUSE. You will need to make the following configuration change to make it work. In the file /etc/sysconfig/displaymanager, change the line:
and run SuSEconfig. Note that this functionality is switched off by default because it is a potential security risk. For most purposes, using ssh -X allows you to do all the remote displaying that you need to do.
The display manager is the program that handles graphical logins and gives you an X session when you log in. If you chose KDE to be your desktop environment at install time, then you probably have the KDM display manager: similarly, if you chose GNOME, you probably have GDM. However, either of these display managers can start a session of the other graphical environment. At log in time, you can select from the "Session" menu the window manager or graphical environment you wish to run.
It is also possible to log in graphically and remotely to wiley from bible and see exactly what you would see if you were in front of wiley's monitor.
To make this possible, you need to do some configuration on wiley. Edit the file /etc/sysconfig/displaymanager and change the line
so that it reads
Then run SuSEconfig. The next time the display manager (gdm, xdm, or kdm) is started, remote logins to this machine will be possible.
r ! i j Remote graphical logins are handled by X display manager control protocol (XDMCP).
By default, XDMCP works only on the local subnet and should be considered insecure because authentication information is not encrypted. For secure remote graphical access consider using NX (discussed later in this chapter).
Now, on bible, you can type the following command:
If a graphical environment was already running on bible, this will start a second X session on the second display (:1 is second when we count from 0), and you should now see wiley's graphical login screen; you can log in to wiley as any user on wiley and work in your desktop there. You can go back to your previous graphical session with the key combination Ctrl+Alt+F7, and return to this new one with Ctrl+Alt+F8.
You can have more than one display running on the same machine in X. On a SUSE system the first display (the one you normally see) can be accessed with the key combination Ctrl+Alt+F7. If there is a second display running, it will be available by pressing Ctl+Alt+F8, and so on.
Another way to do the same thing is provided by the "start menu'' in either KDE or GNOME. There is an entry under "Leave" labeled "Switch user: Manage Parallel Sessions.'' This allows you to log in again to the local machine, but also to log in to a remote session through the main login screen. If you are using KDM, choose "System" then "Remote login'' as shown in Figure 8-3. If you are using GDM, unfortunately, this option is not available by default on the login screen.
If graphics were not running on bible (say it was in runlevel 3), then the command [email protected]: ~> X -query wiley will get you to the login screen in wiley on the first display on bible (Ctrl+Alt+F7 to access it).
Choosing Remote Login at the KDM login screen
Remote Graphical Connection from Windows
There are ssh clients for Windows, the best known of which is PuTTY. If you want to view your Linux desktop from a remote Windows machine, one easy way is to use PuTTY together with Virtual Network Computing (VNC). You will need to have the tightvnc package installed on Linux, and you will need to have PuTTY and a VNC viewer available on Windows. These applications are provided in the dosutils directory on your SUSE distribution media, but you can always get the latest and greatest versions directly from their home sites. PuTTY is available from www.chiark.greenend.org.uk/ ~ sgtatham/putty/. A VNC viewer for Windows is available from www.realvnc.com. It appears that version 3.3.5 of the Windows viewer works best with the tightvnc package included in current versions of SUSE.
Use PuTTY to log in to your Linux machine from Windows. When you are logged in, do this: [email protected]:~>vncserver
You will require a password to access your desktops. Password:
When you have set the password, you will see something like this: New 'X' desktop is bible:1
Creating default startup script /home/user/.vnc/xstartup Starting applications specified in /home/user/.vnc/xstartup Log file is /home/user/.vnc/bible:1.log
You can now start the VNC viewer on the Windows machine and connect to bible:1 (or the appropriate IP number followed by :1). The :1 is the display number; the VNC server takes the next available display number, and you have to supply the same number to connect to it. You will see a Linux desktop (in fact, running twm as a window manager). If you normally use KDE and you would like to see your usual KDE desktop, you need to edit the file ~ /.vnc/xstartup and replace twm & with startkde &.
Note that you can also connect to the VNC server through a (Java-enabled) browser by using the address http://bible:5801 — the port number is 5800 plus the display number.
r : r j You can do the same thing by activating Remote Administration capabilities in YaST.
The krfb desktop sharing program is also included as part of KDE in SUSE; this allows you to share your current session with another user through the VNC protocol. The krfb program creates a session password and offers the invitation for a limited period of time. Someone can connect to the session from any VNC client elsewhere on the network, but in this case they will be literally sharing the same desktop session — both users can use the keyboard and mouse and the effects will be seen on both displays. The same facility is offered by the vino package, which is part of the GNOME desktop.
Of course, you can also run a VNC server on Windows and access the Windows desktop using the Linux vncciewer or krdc programs, or you can use these to access your Linux desktop from another Linux machine.
Alternatively, you can run a full X server in Windows. Free alternatives include the Java-based weirdx, which is included in the dosutils directory on the SUSE distribution, and cyg-win/X, which is part of Cygwin, which provides a complete Unix-like environment on Windows.
Cygwin/X is available from http://x.cygwin.com/ and is easy to install and run on Windows. When you run the installer, you will find that because of dependencies, you install a considerable proportion of the entire Cygwin environment in order to run X. You can then click the Cygwin icon to get a shell, type (for example) X -query wiley, and you can log in graphically to the remote Linux machine.
There are also a number of proprietary X server implementations for Windows. These include Labtam's XConnectPro software, available from www.labtam-inc.com, and Hummingbird Communications Exceed (www.hummingbird.com/products/nc/exceed/).
Was this article helpful?