I can connect to a remote server with Tramp

C-x C-f /ssh:group@remotehost:

and get a plot output window (with ess R). But if I change user

C-x C-f /ssh:group@remote|su:user@remote:

there's no X11 forwarding anymore, i.e. not output window. Here's the error reported in R:

Error in .External2(C_X11, d$display, d$width, d$height, d$pointsize,  : 
  unable to start device X11cairo
In addition: Warning message:
In (function (display = "", width, height, pointsize, gamma, bg,  :
  unable to open connection to X11 display ''

My ssh config file has ForwardX11 yes and ForwardX11trusted yes as described in Tramp manual. Am I missing something in my ssh config file or emacs init file, or is it on the server side?

  • 1
    su does break X11. Can you use SSH to switch to the other user account? X11 forwarding will just work if you do two steps of SSH each with X11 forwarding enabled, whereas su doesn't do X11 forwarding. Oct 20, 2018 at 7:15
  • Thanks @Gilles, but only user group is allowed to ssh to that server, not user user.
    – Denis
    Oct 22, 2018 at 12:29

1 Answer 1


Workaround (?), before a more straightforward (i.e. "automated") solution, based on this answer: open a terminal as group and do:

xauth list

Copy the last line from the list and, in another terminal as user, do:

xauth add the_copied_line



(or whatever the number you've got in the copied line).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.