I ssh ( with -X option ) to another computer then I I do a chroot.

I then encounter problems running X11 apps.

As one example, after the ssh I would run emacs and it would open a new window as a X11 app. After running the chroot and doing ssh I would see emacs running as a console app.

I don't get errors since emacs can be run it as an X11 app or a console app, but with other GUI apps I get the error message:

"cannot open display: localhost:10.0"

PS: Just to head off anyone who wants to suggest checking $DISPLAY, that is set correctly.

I was wondering if there are any logs to check to see if I can identify the problem.


Take a look at this thread on Super User titled: How do I fix a “cannot open display” error when opening an X program after ssh'ing with X11 forwarding enabled?

Given you're able to ssh using the first account you're ssh'ing in with your issue isn't with this:

# /etc/ssh/sshd_config
X11Forwarding yes

It's likely that now that you've chroot'ed you no longer have access to your .XAuthority file on your local side. This file is required in order to manage the remote displaying of X applications.

See the xauth and mkxauth man pages for more details.

Also if you're unfamiliar with how X's $HOME/.Xauthority and the MIT-MAGIC-COOKIE's mechanisms work there is a good primer here titled: Lack of .Xauthority, on how it works.

  • Unfortunately it seems the mkxauth program isn't available for Debian. – Mouse.The.Lucky.Dog May 2 '13 at 22:21
  • I don't think it's the .Xauthority. Listing the cookies in the initial environment and the chroot environment shows the same cookies. – Mouse.The.Lucky.Dog May 2 '13 at 22:39
  • How about if you move the existing .Xauthority file out of the way and create a new one? Also this chrooted environment has a full complement of X tools? Curious how it's able to call the various tools to manipulate the .Xauthority file in that env. – slm May 2 '13 at 23:03
  • Also can you please explain your chroot command a little bit more? I'm having a hard time understanding what your environment looks like after you run it. Do you have access to all the same tools you had access to prior in this chroot environment? xauth? ls? etc. – slm May 2 '13 at 23:55

In addition to the .Xauthority file mentioned in the other answer, your chroot would also need to have the X socket in it. ssh -X doesn't forward X over an abstract socket, only over a UNIX socket with path. If your chroot doesn't have /tmp/.X11-unix bind-mounted into it, programs in your chroot can't connect to the X server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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