How to forward a Program Display from a Remote Linux Server using X11

Introduction

Software is usually installed via command-line tools. It can be automated, scheduled, and repeated with minimal effort. However, for quick testing and demo purposing, or when you are new to some products, you might prefer discovering the new options using a graphical interface. For example, when installing Oracle Grid Infrastructure, Oracle Database, or Oracle Database Client. Tip: when you need an Oracle Database and quickly get started, just provision one on Oracle Cloud, fully automated.

This blog post provides a step-by-step guide on enabling X11 on your Linux server and forwarding the program display to your local Windows machine.

The Environment

  • Oracle Linux VM on Oracle Cloud.
  • Local Windows machine with PuTTY as SSH client and Xming as X Window server.

Preparation

Step 1: Install PuTTY and Xming

Download and install PuTTY and Xming on your local Windows machine.

Step 2: Install the required packages on the Linux server

On your Linux server, install the xorg-x11-xauth package:

sudo yum install xorg-x11-xauth -y

Step 3: Configure X11 forwarding on the Linux server

On your Linux server, make sure that /etc/ssh/sshd_config file contains the following option:

sudo vi /etc/ssh/sshd_config
...
X11Forwarding yes
...

If you made changes to the sshd_config file, restart the sshd service:

sudo systemctl stop sshd.service
sudo systemctl start sshd.service
sudo systemctl enable sshd.service

Connection

Step 4: Configure and start Xming

Configure and start Xming via the provided XLaunch utility. Search for the XLunch application and start it. Keep the defaults, click Next, then Finish:

Step 5: Establish an SSH connection via PuTTY

In your PuTTY session, enable the X11 forwarding checkbox and establish the connection:

Step 6: Test display forwarding

To test the display forwarding, install and start the xclock application:

sudo yum install xclock -y
xclock

The clock graphical application will be shown on your Windows machine:

Xming will show the currently 1 client connected.

Troubleshooting

If you are still getting the “Can’t open display” error message. Restart your PuTTY session. When the session opens, you might see the “file /home/opc/.Xauthority does not exist” message. Nevertheless, display forwarding will work now. The message does not appear anymore when you start a new session again.

 

How to Create SSH Keys Using Oracle Cloud Shell

The SSH (Secure Shell) protocol is a method for secure remote login from one computer to another. SSH enables secure system administration and file transfers over insecure networks using encryption to secure the connections between endpoints. SSH keys are an important part of securely accessing Oracle Cloud Infrastructure compute instances in the cloud.

Oracle always recommend you use the Oracle Cloud Shell to interface with the OCI compute instance you will create. Oracle Cloud Shell is browser-based, does not require installation or configuration of software on your laptop, and works independently of your network setup.

To use the Cloud Shell machine, your tenancy administrator must grant the required IAM (Identity and Access Management) policy.

  • To start the Oracle Cloud shell, go to your Cloud console and click the cloud shell icon at the top right of the page.

  • Once the cloud shell has started, Choose the key name, This will be the keyname you will use to connect to any compute instances you create. Press Enter twice for no passphrase.
mkdir .ssh
cd .ssh
ssh-keygen -b 2048 -t rsa -f <<sshkeyname>>

Please find the below notes which I has done.

osamaobama@cloudshell:~ (us-phoenix-1)$ mkdir .ssh
osamaobama@cloudshell:~ (us-phoenix-1)$ cd .ssh
osamaobama@cloudshell:.ssh (us-phoenix-1)$ ssh-keygen -b 2048 -t rsa -f cloudshellkey
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in cloudshellkey.
Your public key has been saved in cloudshellkey.pub.
The key fingerprint is:
SHA256:VJLFZbU6v2PHzCJtWKHNEgV8UH7RGpFXny63PvXDatM osamaobama@5e3feabe028c
The key's randomart image is:
+---[RSA 2048]----+
| .+oo==+++|
| .o....=.*|
| . oo=o|
| . ..+. |
| S o* + |
| oo* o|
| =+=o|
| ooBE*|
| .=+=o|
+----[SHA256]-----+
osamaobama@cloudshell:.ssh (us-phoenix-1)$ ls
cloudshellkey cloudshellkey.pub
osamaobama@cloudshell:.ssh (us-phoenix-1)$ cat cloudshellkey.pub 
ssh-rsa AAAAB3NzaC1yc**********************************************
osamaobama@cloudshell:.ssh (us-phoenix-1)$

Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Ramkumar’s LinkedIn: https://www.linkedin.com/in/ramkumardba/
LinkedIn Group: https://www.linkedin.com/in/ramkumar-m-0061a0204/
Facebook Page: https://www.facebook.com/Oracleagent-344577549964301
Ramkumar’s Twitter : https://twitter.com/ramkuma02877110
Ramkumar’s Telegram: https://t.me/oracleageant
Ramkumar’s Facebook: https://www.facebook.com/ramkumarram8