Error `No protocol specified` when running from remote machine via ssh

135,978

Solution 1

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.

Solution 2

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"

Solution 3

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.

Solution 4

Debian Jessie, add also:

export XAUTHORITY=/.Xauthority

Solution 5

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

export DISPLAY=:0.0

to

export DISPLAY=:10
Share:
135,978

Related videos on Youtube

TPS
Author by

TPS

Updated on September 18, 2022

Comments

  • TPS
    TPS over 1 year

    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?

  • vimdude
    vimdude almost 9 years
    xhost + will give access to anybody to connect to your display. I would recommend xhost +local:[hostname or ip]
  • Melroy van den Berg
    Melroy van den Berg almost 6 years
    xhost + fixed my problem (on the client side)
  • elpie89
    elpie89 over 5 years
    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
  • Yug Singh
    Yug Singh over 4 years
    This and this is what fixed the error for me. +1