Search code examples
unixfirefoxredhatcupsmobaxterm

user not able to launch firefox from unix- X11 error


Using MobaXTerm on RedHat, I am able to launch Firefox from my user profile and access browser GUI. However if I sudo to root and try to launch firefox I get an error:

         X11 connection rejected because of wrong authentication.

I want to access CUPS in the browser with root access so that I can administer printers from GUI (not trying to browse as root!). I am aware that all of the administration can be done from command line, but sometimes the GUI is just easier.

How can I resolve this error so that I may launch firefox as root?


Solution

  • Under my user profile where firefox is working, run:

             xauth list
    

    The output will be something like:

    servername/unix:11  MIT-MAGIC-COOKIE-1  256d99dc3f0f7acdf90190a2710d7042
    servername/unix:11  MIT-MAGIC-COOKIE-2  61f888d3342b65f4f05f02fcb708f3d8
    servername/unix:11  MIT-MAGIC-COOKIE-3  656d49dc3f0f7acdf96190a2710d7042
    

    Copy the list of these entries.

    Then sudo to root and run xauth list again. You will find a different list of cookies.

    To repair the trouble, add each of the cookie under my user profile to root's profile via xauth add command:

    xauth add servername/unix:11  MIT-MAGIC-COOKIE-1  256d99dc3f0f7acdf90190a2710d7042
    

    As far as I know each cookie needs to be added one at a time, but someone jump in if they know of a bulk method.

    After adding the cookies to root profile, Firefox can be launched from root.

    Thanks to Byron for the help on this.