Thursday, 3 April 2014

Xlib: PuTTY X11 proxy: wrong authentication protocol attempted

GUI installer fails to launch when executed with sudo


Problem:
 Application GUI installer fails to launch by throwing X related error messages when executed with sudo.
Scenario:
Application team has to install application with root privilleges but security policy does n't allow sharing root password.Here we provided necessary privilleges to the application user via sudo.But when the application user tried to start the install script which invokes a gui
got the following error messages:
Xlib: connection to "localhost:10.0" refused by server
Xlib: PuTTY X11 proxy: wrong authentication protocol attempted
Error: Can't open display: localhost:10.0
Reason:
To get remote display exported to our local machine we need to have proper DISPLAY variable and X authentication for our X server(xming in our case).When the user logs in via ssh client,putty...DISPLAY variable will be set according to the putty X11forwarding configuration,and proper X authentication will be set up by adding entry to ~user/.Xauthority file.When we use sudo to get root privilleges X authentication will be expected from root user's configuration file(/.Xauthority).As the X authentication is updated to ~user/.Xauthority file while logging in to the OS directly via ssh; root user's Xauthority file will not have this information.This is why we get "Xlib: connection to "localhost:10.0" refused by server" message.

Work around:
I just created a softlink from ~user/.Xauthority to ~root/Xauthority.
eg:
# ln -s ~user/.Xauthority  /.Xauthority
This enabled root user to have proper X authentication to connect to xserver(xming) on the local machine.

Note:
When we switch to root user we have to set DISPLAY variable additionally by looking into the DISPLAY variable of the first login.
Eg:
$ echo $DISPLAY
localhost:10.0

$su -

# export DISPLAY=localhost:10.0

No comments:

Post a Comment

Kubernetes cluster setup on Ubuntu 26.04 using Kubeadm

Step1: Disable swap memory: Kubernetes requires swap to be disabled for the kubelet to function correctly # swapoff -a # sudo sed -i '/...