HOW TO USE GUI BASED APPLICATIONS IN LINUX ENVIRONMENTS – PART 1

Sometimes we as sysadmins, need to use Graphical User Interface (GUI) in addition most commonly used ssh terminals. The purpose may be to install software like oracle or accessing graphic applications that are installed only on remote machines. Unix based GUI technologies like X11 or VNC are always confusing to me and I used to rely on my colleagues. Recently, I got to install weblogic on Oracle Cloud Infrastructure (OCI). I invoked installer but no GUI window opened. My colleague, Rohit, configured everything on the VM for me. But this time I wanted to understand how these systems work under the cover so that I can troubleshoot these issues myself next time and save my colleagues’ time :-). In first part of the series, I will explain how to use X11 windows system for GUI in Oracle Cloud Infrasture (OCI). The same steps can be followed in any other Linux environment. In second part, I will try to explain how things work behind the scenes.

For accessing X11 GUI remotely we need to have X server installed in our local system. We can use X servers like Xming. I prefer to use MobaXterm as it has both ssh client and X server. Let us see how to open GUI using both methods.

MobaXterm:
1. Install Xauth: sudo yum install xorg-x11-xauth
2. Install Xclock: sudo yum install xclock (This step is not mandatory. xclock is usually used to check if X11 setup is working correctly.)
3. Uncomment X11Forwarding and set X11UseLocalhost to no in /etc/ssh/sshd_config


4. Restart sshd daemon service: sudo systemctl restart sshd
5. Re-login to remote server and run xclock. It should open xclock as shown below. This confirms that x11 is working fine.


Note: .Xauthority which is used for authentication is automatically created by xclock. If you are not planning to install it, you need to create it manually.
In some shops, direct access to installation user is restricted and sysadmin has to swithc user something like: sudo su -u oracle. In this case, X11 applications will fail with following error due to missing authorization information:

[oracle@vm4 opc]$ xclock
MoTTY X11 proxy: Unsupported authorisation protocol
Error: Can't open display: 10.0.0.10:10.0

Follow below errors to fix the issue:

1. List current magic cookies using xauth:

[opc@vm4 ~]$ xauth list
vm4/unix:10 MIT-MAGIC-COOKIE-1 2928a6e16b7d6d57041dcee632764b72
vm4:12 MIT-MAGIC-COOKIE-1 a4d351aa0e24b5a56cbf4fe4c1e79886
vm4:11 MIT-MAGIC-COOKIE-1 421eb3fb275fffeb22c29ae3328a13a9
vm4:10 MIT-MAGIC-COOKIE-1 96e89b74c16a34c0601b662e78a73b30


2. Switch to application user.
[opc@vm4 ~]$ sudo -su oracle bash

3. List the current DISPLAY variable.

[oracle@vm4 opc]$ echo $DISPLAY
10.0.0.10:10.0


4. Add the cookie corresponding to DISPLAY from earlier user:
[oracle@vm4 opc]$ xauth add vm4:10 MIT-MAGIC-COOKIE-1 96e89b74c16a34c0601b662e78a73b30
xauth: file /home/oracle/.Xauthority does not exist
[oracle@vm4 opc]$ touch /home/oracle/.Xauthority
[oracle@vm4 opc]$ xauth add vm4:10 MIT-MAGIC-COOKIE-1 96e89b74c16a34c0601b662e78a73b30

5. Run xclock command to confirm that X setup is working.

Xming:
If you don’t prefer to use MobXterm, X11 applications can also be accessed using X Windows display servers like Xming in conjunction with ssh client like Putty. Follow below steps:

  1. Install Xming by downloading from here.
  2. Xming display server automatically starts after installation. When you restart your laptop, start Xming server by clicking on its icon.
  3. Uncomment X11Forwarding and set X11UseLocalhost to no in /etc/ssh/sshd_config
  4. Restart sshd daemon service: sudo systemctl restart sshd
  5. Open Putty Session, enable X11 forwarding (Connection -> SSH -> X11), enter X display location as shown below:

  1. 6. Open ssh session in Putty. You may need to add private key in SSH -> Auth if you are using key based authentication to login into remote server.
  2. 7. Run xclock command to verify X windows setup is working fine.
  3. 8. If you have to switch to a different user to launch X applications, copy magic cookies as mentioned earlier in this blog.

VNC:
If your remote server is installed with desktop environment, you can use vnc to connect to remote server desktop and access graphic applications. The detailed steps to install desktop software on remote machine can be found in this nicely written oracle ateam blog.



Comments

Popular posts from this blog

HOW WE REDUCED SOA OSB PROVISIONING FROM 4 DAYS TO 4 HOURS

NOT ABLE TO START RABBITMQ CLUSTER: CANNOT DECLARE A QUEUE ‘~S’ ON NODE ‘~S’: ~255P

SOA SUITE 12.2.1.4 INSTALLATION: GOT EXCEPTION WHEN AUTO CONFIGURING THE SCHEMA COMPONENT(S) WITH DATA OBTAINED FROM SHADOW TABLE