I have 2 virtual machines, one running CentOS 7 and the other one CentOS 6.5. I'd like to run an application on the CentOS 6.5 VM but display it on the 7 one.

I cannot use ssh -X (or -Y), I have to use xeyes -display host:displaynumber, but I can't manage to make it work for now.

What I'm trying, from the 6.5VM, is: xeyes -display

I get the following:

No protocol specified
Error: Can't open display:

However, when I ssh -X (from the 6.5VM), then xeyes, it does work correctly, (and by correctly I mean that it successfully connects to the 7VM and the xeyes app is displayed on the 6.5VM) so I don't think it is an issue with the hostname. Doing the other way around (meaning, I ssh from the 7VM to the 6.5VM to launch xeyes) works correctly too.

echo $DISPLAY gives :0 on both machines. I did add X11Forwarding yes to /etc/ssh/sshd_config. (and AllowTcpForwarding yes too)

Feel free to ask for more information if I forgot something. I'm a bit of a newb so I may have forgotten simple details.

Thanks in advance for any answer!

  • 1
    First check if the Xorg server on the 7VM is really listening on port 6000 (it's not the default on newer systems!) and if the 6.5VM is able to connect to it. Then try copying the auth from the 7VM to the 6.5VM by running on the 6.5VM; ssh user@ xauth extract - :0 | xauth merge -. Notice that X11Forwarding in sshd_config only affects ... X11 forwarding (allows you to use ssh -X or -Y), and when using X11 forwarding DISPLAY should NOT be :0. – mosvy Oct 11 '19 at 8:01
  • And to make it listen on port 6000: Add -listen tcp, and make sure that -nolisten is not present when starting the X server. Also be aware that X over LAN is inherently unsecure, even with xauth. – dirkt Oct 11 '19 at 8:03
  • xapp -display host:number is telling xapp to connect to port 6000 + number on host; it will not use X11 or any other forwardings you may have set up on the machine it runs on. – mosvy Oct 11 '19 at 8:03
  • @dirkt I'm sorry if I come across as ignorant, but where am I supposed to add this? – ImranD Oct 11 '19 at 8:26
  • @mosvy I first wrote a comment but noticed I was wrong, sorry for the notification. Here's what I was saying, but corrected: I forgot to say that, but I followed this answer. sudo netstat -tulpn | grep 6000 shows LISTEN for this port. However, telnet 6000 is not able to connect. As to copying the auth, your command gives me this: No matches found, authority file "-" not written; xauth: (argv):1: unable to read any entries from file "(stdin)" – ImranD Oct 11 '19 at 8:31

Partial answer:

X servers can listen both on a unix domain socket (for local connections) and on a TCP port (6000 + display number). The latter is disabled by default on modern servers, which could be a reason why you can't connect.

So, on the server you want to connect to (the 7 VM), do ps axu | grep X or similar, and have a look at the commandline the X server was started with. If there's a -nolisten or -nolisten tcp, it has to go; and you have to add a -listen tcp.

Now there are several ways to start an X server, and I don't know which your system uses. So look at the parent process id (PPID) of the X process, do some more ps invocations, and see if you can figure it out. Could be a display manager (e.g. gdm or kdm), or possibly systemd. Whatever started it needs to be configured for those commandline options.

If the server is properly listening on port 6000, the next step is to check firewall rules (iptables).

  • 1
    I finally got it working. I've done xhost + on 7VM and added 6000 port with tcp protocol to the firewall and it worked. I don't know which one of these made it work though. Maybe both? Anyways, thanks for your help ! – ImranD Oct 11 '19 at 9:11
  • Very likely the xhost +. – dirkt Oct 11 '19 at 9:13

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.