Skip to content

Instantly share code, notes, and snippets.

@onggunhao
Last active January 5, 2023 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onggunhao/71569fc5ecc3f4dffa60f54d36549909 to your computer and use it in GitHub Desktop.
Save onggunhao/71569fc5ecc3f4dffa60f54d36549909 to your computer and use it in GitHub Desktop.
Fixing "X11 connection rejected because of wrong authentication" when running gnome-terminal

Fixing X11 connection rejected errors

This is written for newcomers to the lab, who often experience X11 connection rejected errors when running gnome-terminal (you need this to run atom, sublime text etc to edit on a remote server).

For more info, read the full answer on StackExchange https://unix.stackexchange.com/questions/412065/ssh-connection-x11-connection-rejected-because-of-wrong-authentication

1. Log onto remote server (Andromeda)

echo $DISPLAY This should display your current X11 display

xauth list If nothing prints on console, it means ssh did not automatically generate the X11 authorization cookies on the local display properly

2. Add the authorization cookie

xauth add $DISPLAY - `mcookie This adds your display's authorization cookie to the xauth

xauth list Check whether your display is added

3. Merge your cookie with your local machine

xauth nextract ~/xccookie $DISPLAY

exit

On local: scp user@remote:~/xcookie ~/xcookie

On local: xauth nmerge ~/xcookie

4. Login and run gnome-terminal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment