8

I have a script, simply to run my Graphical (GUI) Application, as below.

#cat gui.sh
#!/bin/bash 
./gui -display 127.0.0.1:0.0    

When I run it from local machine (./gui.sh) it runs perfectly fine. But when I am trying to run it from remote machine via ssh, I got following error.

[root@localhost]# ssh -f 192.168.3.77 "cd /root/Desktop/GUI/ && "./gui.sh""   
No protocol specified  
gdm: cannot connect to X server 192.168.3.77:0.0   
[root@localhost]#    

I don't know, which protocol it is asking or am I missing anything? I tried directly by starting the application, without script [ssh -f 192.168.3.77 "cd /root/Desktop/GUI/ && "./gui""], but the result is same. I have tried various combinations like ssh -Y, ssh -fY and more but the result is same!
Secondly for my application, there is a must condition that, we have to first go into the directory where the program is located.
Any Solutions?

5

The meaning of the option -display 127.0.0.1:0.0 depends on that gui program, but it's highly likely that it means “display on the X display 127.0.0.1:0.0”. This is the first local X display, accessed over TCP. This is almost certainly wrong for two reasons. First, the local X display should be :0, not 127.0.0.1:0, because including an IP address causes the traffic to go through TCP instead of local access. Going through TCP may not work depending on whether the X server accepts TCP connections. Even if it does, you lose the optimizations that local displays have.

The display to use is normally indicated by the DISPLAY environment variable, and that variable tends to be set correctly automatically. (Usually, if DISPLAY has the wrong value, it's because you've been messing with it. The main exception is use of screen or tmux.)

Your program probably does look up the value of the DISPLAY environment variable, because that tends to happen automatically with xlib calls. So you should just call ./gui, your script doesn't do anything useful. If your program insists on the -display argument, make it use the environment variable:

./gui -display "$DISPLAY"
4

ssh -Y and ssh -X should be a good start but did you forward your X server as well?

$ grep X /etc/ssh/sshd_config
X11Forwarding yes

otherwise it won't work.

Another thing to check is the DISPLAY variable it should show something like this:

$ echo $DISPLAY
$ localhost:10.0

this was run after ssh -Y. The same variable is empty if I ssh without -Y or -X.

For differences between -X and -Y read the man page of ssh.

2

This video explains how to solve the error step by step. If you don't wan't to watch then follow the text below:

The No protocol specified error indicates that "the user doesn't know how to launch a GUI application" and the "user doesn't have permissions to launch a GUI application". In the video the GUI application is dbca.

The key piece of this video is in running the command xhost + which grants the user permissions to remotely display a GUI from a remote system, to the local system.

  • 6
    xhost + will give access to anybody to connect to your display. I would recommend xhost +local:[hostname or ip] – vimdude Apr 21 '15 at 12:58
0

I was hit by same issue I resolved it by changing the DISPLAY environment variable from:

export DISPLAY=:0.0

to

export DISPLAY=:10
0

Debian Jessie, add also:

export XAUTHORITY=/.Xauthority
  • xhost + fixed my problem (on the client side) – danger89 Apr 24 '18 at 11:31
  • That helped, thank you! My XAUTHORITY was /tmp/xauth-1000-_0 but after starting two additional X sessions that file had disappeared - only the third one remained. To fix the problem for all windows I restored it with: ln -s ~/.Xauthority /tmp/xauth-1000-_0 – joeytwiddle Dec 21 '18 at 0:54

protected by GAD3R Dec 19 '17 at 14:38

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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