ssh, sudo and X forwarding

After you ssh into a unix/linux box and sudo into another user account, you get:

X11 connection rejected because of wrong authentication.


$ echo $DISPLAY

You get something like:

localhost: 11.0

Then do:

$ xauth list

and you’ll see something like:

$ xauth list $DISPLAY You’ll get something like:

somehost/unix:1o MIT-MAGIC-COOKIE-1 ee4873663c9ddfaeae3283b64230891b

Then, after having done sudo, tell the new user what the cookie is:

$ xauth add somehost/unix:12 MIT-MAGIC-COOKIE-1 ee4873663c9ddfaeae3283b64230891b


Leave a Reply