Changes

Displaying RHEL Applications Remotely (X11 Forwarding)

8,411 bytes added, 18:39, 10 June 2019
Created page with "{{#pagetitle: Displaying RHEL 8 Applications Remotely (X11 Forwarding) }} <table border="0" cellspacing="0" width="100%"><tr> <td width="20%">RHEL Remote Desktop Access with..."
{{#pagetitle: Displaying RHEL 8 Applications Remotely (X11 Forwarding) }}
<table border="0" cellspacing="0" width="100%"><tr>
<td width="20%">[[RHEL Remote Desktop Access with VNC|Previous]]<td align="center">[[Red Hat Enterprise Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Using NFS to Share RHEL Files with Remote Systems|Next]]</td>
<tr>
<td width="20%">RHEL 8 Remote Desktop Access with VNC<td align="center"><td width="20%" align="right">Using NFS to Share RHEL 8 Files with Remote Systems</td>
</table>
<hr>


<htmlet>rhel8</htmlet>


In the previous chapter we looked at how to display the entire RHEL 8 desktop on a remote computer. While this works well if you actually need to remotely display the entire desktop, it could be considered overkill if all you want to do is display a single application. In this chapter, therefore, we will look at displaying individual applications on a remote system.

== Requirements for Remotely Displaying RHEL 8 Applications ==

In order to run an application on one RHEL 8 system and have it display on another system there are a couple of prerequisites. First, the system on which the application is to be displayed must be running an X server. If the system is a Linux or UNIX-based based system with a desktop environment running then this is no problem. If the system is running Windows or macOS X, however, then you must install an X server on it before you can display applications from a remote system. A number of commercial and free Windows based X servers are available for this purpose and a web search should provide you with a list of options.

Second, the system on which the application is being run (as opposed to the system on which the application is to be displayed) must be configured to allow SSH access. Details on configuring SSH on a RHEL 8 system can be found in the chapter entitled [[Configuring SSH Key-based Authentication on RHEL|Configuring SSH Key-based Authentication on RHEL 8]].

Finally, SSH must be configured to allow X11 forwarding. This is achieved by adding the following directive to the SSH configuration on the system from which forwarding is to occur. By default on RHEL 8, the ''/etc/ssh_config'' file contains a directive to include all of the configuration files contained in the ''/etc/ssh/ssh_config.d'' directory:

<pre>
Include /etc/ssh/ssh_config.d/*.conf
</pre>

''05-redhat.conf''. Edit this file and add a line to enable X11 forwarding as follows:

<pre>
.
.
Host *
GSSAPIAuthentication yes
X11Forwarding yes
.
.
</pre>

After making the change, save the file and restart the SSH service:

<pre>
# systemctl restart sshd
</pre>

Once the above requirements are met it should be possible to remotely display an X-based desktop application.

== Remotely Displaying a RHEL 8 Application ==

The first step in remotely displaying an application is to move to the system where the application is to be displayed. At this system, establish an SSH connection to the remote system so that you have a command prompt. This can be achieved using the ''ssh ''command. When using the ''ssh'' command we need to use the -X flag to tell it that we plan to tunnel X11 traffic through the connection:

<pre>
$ ssh -X user@hostname
</pre>

In the above example ''user'' is the user name to use to log into the remote system and ''hostname'' is the hostname or IP address of the remote system. Enter your password at the login prompt and, once logged in, run the following command to see the DISPLAY setting:

<pre>
$ echo $DISPLAY
</pre>

The command should output something similar to the following:

<pre>
localhost:10.0
</pre>

To display an application simply run it from the command prompt. For example:

<pre>
$ gedit
</pre>

When executed, the above command should run the ''gedit'' tool on the remote system, but display the output on the local system.

== Trusted X11 Forwarding ==

If the'' /etc/ssh/ssh_config.d/05-redhat.conf ''file on the remote system contains the following line, then it is possible to use trusted X11 forwarding:

<pre>
ForwardX11Trusted yes
</pre>

Trusted X11 forwarding is slightly faster than untrusted forwarding but is less secure since it does not engage the X11 security controls. The -Y flag is needed when using trusted X11 forwarding:

<pre>
$ ssh -Y user@hostname
</pre>

== Compressed X11 Forwarding ==

When using slower connections the X11 data can be compressed using the -C flag to improve performance:

<pre>
$ ssh -X -C user@hostname
</pre>

== Displaying Remote RHEL 8 Apps on Windows ==

To display RHEL 8 based apps on Windows an SSH client and an X server will need to be installed on the Windows system. The subject of installing and using the PuTTY client on Windows was covered earlier in the book in the [[Configuring SSH Key-based Authentication on RHEL|Configuring SSH Key-based Authentication on RHEL 8]] chapter. Refer to this chapter if you have not already installed PuTTY on your Windows system.

In terms of the X server, a number of options are available, though a popular choice appears to be VcXsrv which is available for free from the following URL:

https://sourceforge.net/projects/vcxsrv/

Once the VcXsrv X server has been installed, an application named ''XLaunch'' will appear on the desktop and in the start menu. Start XLaunch and select a display option (the most flexible being the ''Multiple windows'' option which allows each client app to appear in its own window):


[[File:win_10_configure_windows_x_server.png]]


Figure 16-1

Click the ''Next'' button to proceed through the remaining screens, accepting the default configuration settings. On the final screen, click on the ''Finish'' button to start the X server. If the Windows Defender dialog appears click on the button to allow access to your chosen networks.

Once running, XLaunch will appear in the taskbar and can be exited by right-clicking on the icon and selecting the ''Exit...'' menu option:


[[File:win_10_x_server_running.png]]


Figure 16-2

With the X server installed and running, launch PuTTY and either enter the connection information for the remote host or load a previously saved session profile. Before establishing the connection, however, X11 forwarding needs to be enabled. Within the PuTTY main window, scroll down the options in the left-hand panel, unfold the SSH section and select the X11 option as shown in Figure 166-3:


[[File:win_10_putty_ssh.png]]


Figure 16-3

Turn on the ''Enable X11 forwarding'' checkbox highlighted in Figure 166-4, return to the sessions screen and open the connection (saving the session beforehand if you plan to use it again).


[[File:win_10_putty_X11_settings.png]]


Figure 16-4

Log into the RHEL 8 system within the PuTTY session window and run a desktop app. After a short delay, the app will appear in the Windows desktop in its own window. Any dialogs that are opened by the app will also appear in separate windows, just as they would on the RHEL 8 GNOME desktop. Figure 166-5, for example, shows the RHEL 8 ''nm-connection-editor'' tool displayed on a Windows 10 system:


[[File:win_10_xserver_app_displayed.png]]


Figure 16-5

== Summary ==

For situations where remote access to individual RHEL 8 desktop applications is required as opposed to the entire GNOME desktop, X11 forwarding provides a lightweight solution to remotely displaying graphical applications. The system on which the applications are to appear must be running an X Window System based desktop environment (such as GNOME) or have an X server installed and running. Once X11 forwarding has been enabled on the remote server and a secure SSH connection established from the local system using the X11 forwarding option, most applications can be displayed remotely on the local X server.


<htmlet>rhel8</htmlet>


<hr>
<table border="0" cellspacing="0" width="100%"><tr>
<td width="20%">[[RHEL Remote Desktop Access with VNC|Previous]]<td align="center">[[Red Hat Enterprise Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Using NFS to Share RHEL Files with Remote Systems|Next]]</td>
<tr>
<td width="20%">RHEL 8 Remote Desktop Access with VNC<td align="center"><td width="20%" align="right">Using NFS to Share RHEL 8 Files with Remote Systems</td>
</table>