"No protocol specified" when running vim with sudo
Solution 1
A recent upgrade changed default settings for sudo
. If anyone have this problem check your sudoer
configuration. From an example in the man page:
# Run X applications through sudo; HOME is used to find the
# .Xauthority file. Note that other programs use HOME to find
# configuration files and this may lead to privilege escalation!
Defaults env_keep += "DISPLAY HOME"
Make sure you have something like that in /etc/sudoers
(use visudo
to edit the file if you need to).
EDIT:
I don't know exactly since when, but at least xauth 1.0.9 supports the environment variable XAUTHORITY
. Setting that and leaving HOME untouched, also fixes the protocol warning and is the better solution, as no world-writeable IPC resources (sockets/pipes) are created pointing to root resources (one avenue for privilege escalation). xauth doesn't automatically export the variable to the environment, so the best way is to set it in your shell's initialization.
Solution 2
According to this thread, there are two possible solutions to your problem:
Put the following line in my root users
.bashrc
scriptexport XAUTHORITY=/home/<user>/.Xauthority
then I copied .Xauthority to root also, i.e.
sudo cp ~/.Xauthority /root
and now the warning is gone.
You could also try running via gksudo
.
Anyway, both are worth a try...
Solution 3
Although the question already has some answers, none worked for me completely. I solved it through a combination of above few suggestions and some bits of mine for my Debian distro.
I made a symlink to .Xauthority
file for root and all other users. The problem got resolved for root user, because root has access permissions to that file, but not for other users. I added read-only permission for all other users for .Xauthority file.
#do this for all other users who do not have .Xauthority file
ln -s /home/userwithxauth/.Xauthority .Xauthority
#run the following command to give read only access permission to .Xauthority file
chmod 644 /home/userwithxauth/.Xauthority
Related videos on Youtube
phunehehe
Updated on September 17, 2022Comments
-
phunehehe over 1 year
Recently I start to get "No protocol specified" when using
sudo vim
. It's just a warning I guess, because everything was working normally (I can open, edit and save files). The message doesn't appear if I usesudo -E vim
so I think I did something wrong when editing/etc/profile
recently, but I'm not sure. How can I fix this?-
ninjalj about 13 yearsNot everything is working normally. Mouse support isn't working, it needs a protocol such as gpm or the xterm mouse protocol.
-
-
phunehehe about 13 yearsI copied
.Xauthority
to/root
and that's it! -
phunehehe about 13 yearsNo I was wrong, after rebooting I got "invalid key" error.
-
Adam Byrtek about 13 yearsAs far as I remember the contents of a .Xauthority file changes, so you should symlink it instead of copying.