On Linux or Linux like systems, we can use xauth module to export the x-windows for software installation or managing applications as GUI when working with CLI based Linux/Unix systems.
Xwindows installation on linux server
install the required packaes -
yum install xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps -y
for Oracle also need to install - libXtst
make sure sshd_config file is updated as given below -
[root@techs_vm01 ~]# vi /etc/ssh/sshd_config
[root@techs_vm01 ~]# X11Forwarding yes
Check the DISPLAY setting, else setup the variable -
[techs_admin@techsvm01 ~]$ xauth list $DISPLAY
techsvm01/unix:10 MIT-MAGIC-COOKIE-1 b49c5bd17e0c98e5f3703fffc140ff52
[techs_admin@techsvm01 ~]$ echo $DISPLAY
localhost:10.0
[techs_admin@techsvm01 ~]$ xhost +
[techs_admin@techsvm01 ~]$ sudo su - root
Last login: Wed Jul 31 12:00:43 CEST 2019 on pts/1
[root@techsvm01 ~]# echo $DISPLAY
localhost:10.0
[root@techsvm01 ~]# xclock
Warning: Missing charsets in String to FontSet conversion
[root@techsvm01 ~]#
Important steps to get it working:
i) If you are loggin in a restricted user, make sure to take a xauth display settings:
use command - xauth list $DISPLAY
mylinuxserver:mylinuxuser [/home/linuxuser/usrid] xauth list $DISPLAY
mylinuxserver/mylinuxuser:10 MIT-MAGIC-COOKIE-1 cb5bf1b016e45c4619e6776563ec4438
mylinuxserver:mylinuxuser [/home/linuxuser/usrid]
ii) copy the xauth list $DISPLAY output and switch to the application user
sx su - someapplicationuser OR
sudo -iu someapplicationuser
iii) Now add the copied Magic cookie into the new user's profile, this can be achieved by following command:
xauth add mylinuxserver/mylinuxuser:10 MIT-MAGIC-COOKIE-1 cb5bf1b016e45c4619e6776563ec4438
iv) Now check that xdisplay is exported by running xclock or xeye
If you get below error, that means on your windows machine/laptop you need a xwindows software installed, like xming
mylinuxserver:mylinuxuser [/home/mylinuxuser]> xclock
Error: Can't open display: localhost:10.0
IMPORTANT NOTES TO CONSIDER: –
- Make sure that x11 is exported in your putty session!
if xclock is not installed on your Linux VM/Server, you can use xdpyinfo to check if xwindows setup works or not!
Xdpyinfo is an utility to show/display the info about X-Server state on your linux server
- Sometime its worth using xhost + after above steps
If you still get errors cant open display, then clear all the auth sessions
with the command - uxauth list | cut -f1 -d\ | xargs -i xauth remove {}
and repeat the above steps