Invalid MIT-MAGIC-COOKIE-1 key

It can be disabled by

xhost +
Invalid MIT-MAGIC-COOKIE-1 key  access control disabled, clients can connect from any host


It’s solved until logout only but I need it to be permanent.
Second, is it secure solution ?

Sorry, but to me it is not clear what your problem is. The title says “Invalid MIT-MAGIC-COOKIE-1 key”, but you do not explain if you typed it somewhere, and what you then expected, or if you got that somewhere and if it blocks you to dosomething (what?) you want.

Please try to understand that we are not looking over your shoulder, nor are we involved until now it what you try to achieve, thus a bit explanation might be useful.

I cannot guarantee that this will work. But it worked for me.

  1. logout from your desktop session.
  2. Use CTRL-ALT-F1 to get to a command line
  3. Login at the command line
rm .Xauthority
  1. logout
  2. Use CTRL-ALT-F7 to get back to desktop login screen
  3. Login

That’s it. Apparently different display managers use different formats for the xauth cookie, and complain when they find one that they don’t like. If you switch display manager, the problem might occur again.

General rule of thumb is to avoid using xhost if you’re concerned about security.
A few recent years ago in fact, its functionality was severely scoped (restricted) in new ways to block at least the worst compromises, but unsurprisingly that also killed a number of ways it was commonly used.

Expect more possible changes in the future,
So if you’re creating something that can be expected to still work in the future, try to find a different way to do what you need.

TSU

Thank you, I’ll try to find another solution.

Thank you. I’m sorry I can’t use that because home folder is encrypted in img file and all files are deleted after log out.

Apology for poor describing issue.

Invalid MIT-MAGIC-COOKIE-1 key is output in xterm or xfce4-terminal when I run various program there.

It causes problems when trying to call programs in script. (program can’t be called)