max1528
Posts: 3
Joined: Fri Jan 29, 2016 9:38 pm

Remote display not working

Fri Jan 29, 2016 9:51 pm

I am just starting with the Raspberry Pi 2.

As a test, I am simply trying to start a terminal from an SSH session. SSH into the PI, set the DISPLAY variable, and run lxterminal.

I have the default noobs installation, with no changes except:

I created a user account and added it to sudoers

I ssh into the Pi2 with this account.

I run "export DISPLAY=:0"
I run "lxterminal"

I get back:

Code: Select all

No protocol specified

(lxterminal:954): Gtk-WARNING **: cannot open display: :0
I have searched online for similar issues, and these are most focused typical desktop/x86, although also debian-based. I have added "xhost +localhost" to the global xinitrc file following one suggestion, but this did not change anything. Otherwise, I seem to be doing what I need to.

Any suggestions on next things to try? Thanks!

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Remote display not working

Sat Jan 30, 2016 11:24 am

When you connect using SSH you get a terminal, not a GUI. You need to connect using other methods to get a GUI.

Why are you trying to open lxterminal? You already have one

max1528
Posts: 3
Joined: Fri Jan 29, 2016 9:38 pm

Re: Remote display not working

Sat Jan 30, 2016 1:26 pm

Launching an lxterminal remotely is only a test to launch *something* graphical remotely. I could launch a browser or something else with this test, but lxterminal should work just as well as anything else for this purpose. The end-goal is that I will use a PI with a monitor, but no keyboard/mouse, and will need to control what is on the Pi2's display output remotely via SSH.

I fully understand that a terminal is a terminal and SSH is a remote terminal. I login via SSH, and try to to launch lxterminal on the rapsberry Pi's display. This is something that can be done with the Xserver with that export DISPLAY=:0 item. I have done it before on x86, and if you search, you will see it can be done.

In this case, there seems to be some setup step that I am missing under Rapsbian, or maybe some default configuration that I need to change. This is where I can use some help, if someone here is familiar with default Xserver configuration on the Pi2.

Navyscourge
Posts: 258
Joined: Sat Oct 24, 2015 1:50 pm

Re: Remote display not working

Sat Jan 30, 2016 3:28 pm

Sorry, I didn't understand that from your post.

What device are you using to connect to the Pi? If using windows, you can SSH using Putty, but you need to enable Port Forwarding (Connection, SSH, X11). You then need to run an Xclient on windows (if that is what it is called) like Xming to capture and display the Pi output. I use this all the time, and having loaded both I would run "lxterminal &" (or more often "leafpad myfile &") at the Pi command prompt to get the GUI from the Pi and still have the SSH terminal to type commands with.

Or have I misunderstood again, and you want the display to show on the Pi?

User avatar
Douglas6
Posts: 4982
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Remote display not working

Sat Jan 30, 2016 4:01 pm

max1528 wrote: will need to control what is on the Pi2's display output remotely via SSH.


max1528
Posts: 3
Joined: Fri Jan 29, 2016 9:38 pm

Re: Remote display not working

Sat Jan 30, 2016 4:40 pm

VNC is sort of similar territory, but not quite.

If I log into the PI by SSH, I should be able to launch a graphical application from there, where the display is the desktop on the HDMI output.

This would be most similar if were to launch that graphical application from a terminal on the desktop. Except for since I am logged in by SSH, I need to:

Code: Select all

xhost +localhost   
from a terminal on the desktop, which should instruct the xserver to accept graphical applications launched from an SSH user on localhost (the PI)

Code: Select all

export DISPLAY=:0
to tell graphical applications launched from the SSH session that they should use screen '0' for display

rogerggbr
Posts: 4
Joined: Sun Mar 06, 2016 11:02 pm

Re: Remote display not working

Sun Mar 06, 2016 11:14 pm

I am trying to do a similar thing with the same error so would be interested in any pointers. In my case I am struggling to understand why trying to start a program from a different login screen (either <ctrl> <alt> F1 or by SSH) should give this error:- unable to open display ":0,0"
Further info:- echo $DISPLAY returns :0,0 so that sound good
export DISPLAY=:0,0 returns no errors
What am I missing? Thanks for any help.


rogerggbr
Posts: 4
Joined: Sun Mar 06, 2016 11:02 pm

Re: Remote display not working

Tue Mar 08, 2016 7:14 pm

Thanks for the reply but I still don't understand why my little script fails at the first hurdle. Here is the code:-

Code: Select all

#!/bin/sh

export DISPLAY=:0,0

kweb -JKAr http://www.page I want to display & > /dev/null
while true; do
sleep 30s
WID=$(xdotool search --onlyvisible --class kweb)
xdotool windowactivate $(WID) key alt+r
done
At the moment I am trying to run this from the command line for testing, but obviously the aim is for it to run on startup or on schedule.
Thanks.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3604
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Remote display not working

Tue Mar 08, 2016 8:01 pm

Try with ":0.0" - period, not comma.

rogerggbr
Posts: 4
Joined: Sun Mar 06, 2016 11:02 pm

Re: Remote display not working

Tue Mar 08, 2016 8:07 pm

Thanks Phil, I am so dumb :-)

User avatar
danceswithcrows
Posts: 2
Joined: Sat Mar 12, 2016 9:03 pm
Location: Tempe, AZ

Re: Remote display not working

Sat Mar 12, 2016 9:14 pm

If your Pi is set up in the way that stock Raspbian jessie is set up, the way to execute remote X clients on the Pi via ssh and have them display on your local machine is like so:

Code: Select all

machine:~$ ssh -Y your_pi
your_pi:~$ lxterminal
...the -Y option for ssh enables trusted X11 forwarding, which eliminates the need to set the DISPLAY environment variable or use xhost. This is basically how things have worked with Linux machines and X for years and years. (If you are sshing into a machine where -Y doesn't work, it might be that /etc/ssh/sshd_config has X11Forwarding set to No, but Raspbian jessie sets this to Yes by default. YMMV.)

Please note that remote X clients will be slower than local X clients, and GTK+ X clients may be the slowest. Hope That Helps,

Return to “Advanced users”