Friday, April 25, 2025

What is the reason behind the message: "xauth: file /root/.Xauthority does not exist "?

What does the message that you sometimes see when attempting to launch X applications on a Linux server
"xauth:  file /root/.Xauthority does not exist"
really mean?

It means that the .Xauthority file, which stores X11 authentication cookies, does not yet exist in your home directory (in this case, /root/).

This is common when:

  • X11 forwarding has not been set up or used, yet.
  • You are logging in as root and have not initialized X11 in that session.
  • The file was deleted or never created.

    To work around the issue, follow these steps:

    1. Make sure xauth is installed
    # RHEL/Centos
    su - 
    yum install xauth
    
    #Debian
    apt install xauth
    
    2. Make sure you use the -X flag (X forwarding) when connecting to the server
    ssh -X root@yourserver
    
    3. On the server, edit the file /etc/ssh/sshd_config, and make sure these lines exist and are set to yes
    X11Forwarding yes
    X11UseLocalhost yes
    
    4. Restart ssh daemon
    systemctl restart sshd
    
    5. Try launching a graphical app, like xterm

    If these work, your X11 forwarding is properly set up, and .Xauthority will be created automatically.

    6. If you need to manually create the .Xauthority file

    This is rarely necessary, but you can run:
    touch ~/.Xauthority
    xauth generate :0 . trusted
    
  • No comments:

    Post a Comment