4

I have removed for a mistake my $HOME/.Xauthority file. I want to recreate it without restarting X11. ATM I have start a new X11 session with this command

startx -- :1

but my :0 display still don't run any X11 application. I have tried those commands

rm ~/.Xauthority 
touch ~/.Xauthority
xauth add ${HOSTNAME}/unix:0 . $(xxd -l 16 -p /dev/urandom)
xauth add ${HOSTNAME}/unix:1 . $(xxd -l 16 -p /dev/urandom)
xauth add ${HOSTNAME}/unix:10 . $(xxd -l 16 -p /dev/urandom)
xauth add ${HOSTNAME}/unix:12 . $(xxd -l 16 -p /dev/urandom)
xauth add ${HOSTNAME}/unix:13 . $(xxd -l 16 -p /dev/urandom)

The command xauth list report ok

xauth list

myhost.mydomain/unix:0  MIT-MAGIC-COOKIE-1  blablabla
myhost.mydomain/unix:1  MIT-MAGIC-COOKIE-1  blablabla
myhost.mydomain/unix:10  MIT-MAGIC-COOKIE-1  blablabla
myhost.mydomain/unix:12  MIT-MAGIC-COOKIE-1  blablabla
myhost.mydomain/unix:13  MIT-MAGIC-COOKIE-1  blablabla

but..

xterm -display :0
Invalid MIT-MAGIC-COOKIE-1 keyxterm: Xt error: Can't open display: :0
xeyes -display :0
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0

How to generate a good Xauthority and recover my "lost" :0 display without restarting it?

Edit: I found a pseudo-solution. If you save somewhere the old Xauthority file, or remind the right cookies the X11 display return to work, but if I don't remind the right cookies value?

1 Answer 1

7

You're creating a new cookie and telling clients to use this new cookie. But the server is still using its own cookie. You can't connect to the server to retrieve the cookie without knowing the cookie.

You may be able to obtain the cookie through other means (after all, it exists in the memory of the server process). This would depend on the X server. I don't know if there's a way to do it with Xorg other than searching in the process's memory.

Depending on how the X server was invoked, the cookie may be in a file that still exists. Check the server's command line, for example

ps ww -C Xorg

If there's a -auth argument, check if the file named after it still exists. For example, if you see Xorg … -auth /tmp/serverauth.abcdefgh:

xauth merge /tmp/serverauth.abcdefgh

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.