After changing the host name, gedit (and other X clients) does not open

After changing the host name, gedit does not work as expected, it always shows an error in my root β€œNo protocol”

 ** (gedit:23330): WARNING **: Could not open X display No protocol specified Cannot open display: Run 'gedit --help' to 
+8
authentication ubuntu x11 xorg
source share
4 answers

This will be not only gedit , but in fact all programs that use the X11 protocol to talk to the graphics server. X11 uses the Xauth protocol to authenticate connecting clients. When you log in through some kind of display manager, the MIT-MAGIC-COOKIE-1 check cookie is created and written to your ~/.Xauthority file. This file is read by X11 clients, and the cookies it contains are used to authenticate connections.

The list of cookies in your ~/.Xauthority can be displayed using xauth list :

 $ xauth list localhost:1012 MIT-MAGIC-COOKIE-1 bd988401cbf8xxxxxxxxxxxxxxxxxxxx some.host.example.com/unix:1012 MIT-MAGIC-COOKIE-1 bd988401cbf8xxxxxxxxxxxxxxxxxxxx 

If you change the host name, the X11 client library will no longer be able to find a suitable cookie in the authentication database, and the X11 server will reject the failed connection (unless otherwise specified).

What you can do is add the appropriate cookie using xauth :

 $ xauth add "$(hostname)/unix:0" MIT-MAGIC-COOKIE-1 bd988401cbf8xxxxxxxxxxxxxxxxxxxx 

$(hostname) expands to the result of the hostname command, and unix:0 matches your DISPLAY environment variable set to :0.0 . If it is a different display number, for example. :ddd.0 , you must change the added host entry accordingly to "($hostname)/unix:ddd" . Also note that the value of the added cookie must match the value of the existing one.

If you do not have a terminal emulator at that time, and you cannot open it due to an authentication error, you can switch to the console (text mode), log in there and execute the command above.

+19
source share

Just restart your computer to change the host name.

0
source share

When I changed the name of my laptop, I also experienced this problem. However, I managed to fix it with the following commands

su

(enter password)

cd /etc

gedit hosts

From there, I simply deleted the link to the old computer name and replaced it with the new one.

127.xxx localhost 127.xxx (New Name)

However, remember that whenever you make changes to the name of your computer, you must make sure that the changes are made both in the /etc/hostname file and in the /etc/host file. If you make 1 change without making another, you will receive an error message.

0
source share

jnweiger commented on August 13, 2014 :

The Xauthority file can be written in such a way that the host name does not matter.

I'm not sure if xauth has the correct command line to specify Authentication Family, but I use sed to switch to FamilyWild Family Authentication . We need to change the first 16 bits of nlist . The value of FamilyWild is 65535 or 0xffff .

 xauth nlist :0 | sed -e 's/^..../ffff/' | xauth nmerge - 

In this case, the line written after the family number (usually the host name, etc.) does not matter for the match at all.

The ALT xauth package has recently applied patch to support the addition of such FamilyWild entries via xauth directly with the argument *:0 :

 From bc78aa61cfbddaa27dee275f639ba40de6981b17 Mon Sep 17 00:00:00 2001 From: George V. Kouryachy (Fr. Br. George) <george@> Date: Fri, 4 Aug 2017 18:37:33 +0300 Subject: [PATCH] parse_displayname: use FamilyWild for *:0 --- xauth/gethost.c | 4 ++++ xauth/parsedpy.c | 4 ++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/xauth/gethost.cb/xauth/gethost.c index 8cb58c5..598ac48 100644 --- a/xauth/gethost.c +++ b/xauth/gethost.c @@ -180,6 +180,10 @@ struct addrlist *get_address_info ( * information to be copied and set len to the number of bytes. */ switch (family) { + case FamilyWild: /* was :0 */ + src = "\xff\xff"; + len = strlen(src); + break; case FamilyLocal: /* hostname/unix:0 */ /* handle unix:0 and :0 specially */ if (prefix == 0 && (strncmp (fulldpyname, "unix:", 5) == 0 || diff --git a/xauth/parsedpy.cb/xauth/parsedpy.c index 97988d3..6c98339 100644 --- a/xauth/parsedpy.c +++ b/xauth/parsedpy.c @@ -141,6 +141,10 @@ parse_displayname (const char *displayname, family = FamilyInternet; } #endif + } else if (len == 1 && *displayname == '*') { + /* ALT: wildcard cookie */ + host = copystring("*", 1); + family = FamilyWild; } else if (!dnet && (*displayname == '[') && (*(ptr - 1) == ']')) { /* Allow RFC2732-like [<IPv6NumericAddress>]:display syntax */ family = FamilyInternet6; -- 1.7.3.3 
0
source share

All Articles