User avatar
WJacobC
Posts: 12
Joined: Wed Dec 26, 2012 1:48 am

Startx over SSH

Sun May 26, 2013 9:18 pm

Ok, so I've finally started using my Pi. The problem is, I don't have an HDMI monitor, so I decided to run the Pi from my main PC over SSH. I'm using PuTTY on my Windows 8 PC, and everything is working fine in the command line interface. But when I run 'startx', nothing happens and I have to restart m PuTTY session to access the Pi again. Also, running any X applications from the command line (such as 'midori &') gives me this error:

Code: Select all

Midori - Cannot open display:
I have the XMing X Server software currently running an X Server on my PC (as per the instructions here), so I don't see any reason this isn't working. Please advise me on what do to in order for this to work.

I'm happy to share any more info on my setup and thanks in advance.
Twitter @WJacobC | WJacobC.com

klricks
Posts: 8474
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA

Re: Startx over SSH

Sun May 26, 2013 11:30 pm

You cannot run startx or any GUI applications through SSH.
You need to use RDP or other similar application.
Here is a tutorial on how I set up RDP:
http://64.13.91.137:86/Comp/RPi/RDP.html
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.

dangertux
Posts: 12
Joined: Sun May 26, 2013 11:13 pm

Re: Startx over SSH

Sun May 26, 2013 11:36 pm

klricks wrote:You cannot run startx or any GUI applications through SSH.
You need to use RDP or other similar application.
Here is a tutorial on how I set up RDP:
http://64.13.91.137:86/Comp/RPi/RDP.html
This isn't true. OpenSSH supports forwarding of the Xserver and will very much allow you to run your graphical applications.

See the following : http://itg.chem.indiana.edu/inc/wiki/so ... h/200.html

User avatar
WJacobC
Posts: 12
Joined: Wed Dec 26, 2012 1:48 am

Re: Startx over SSH

Sun May 26, 2013 11:40 pm

Thanks for your reply Klricks. I'll definitely check that out.
klricks wrote:You cannot run startx or any GUI applications through SSH.
This article and other threads here seem to disagree with your statement. I'm not sure whether it is possible or not, but these guys seem to have figured out how to do it. Any ideas anyone?
Twitter @WJacobC | WJacobC.com

sprinkmeier
Posts: 410
Joined: Mon Feb 04, 2013 10:48 am

Re: Startx over SSH

Sun May 26, 2013 11:46 pm

X uses a socket connection between the program and the display to draw things (and the keyboard and mouse to get input).
It uses the DISPLAY environment variable to tell programs how to connect to the display.
The error message you get indicates that DISPAY isn't set, i.e. X forwarding isn't enabled.

You cannot run graphical applications directly through ssh.
What you can do it something called "X forwarding":

Code: Select all

$ ssh -X pi@raspberrypi
$ echo $DISPLAY
localhost:11
$ midori
and run the midori browser on my Pi using my PC as an X-terminal.

You should be able to do this with PuTTY as well (GIYF) but I've never done this myself.
Years ago I set up X forwarding over SSH on Windows boxes using WinGW.
There's also the RDP/VNC option.

https://en.wikipedia.org/wiki/X_terminal
https://en.wikipedia.org/wiki/Secure_Shell#Uses

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 6956
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.

Re: Startx over SSH

Mon May 27, 2013 12:06 am

WJacobC wrote: ...
The problem is, I don't have an HDMI monitor, so I decided to run the Pi from my main PC over SSH. I'm using PuTTY on my Windows 8 PC, and everything is working fine in the command line interface. But when I run 'startx', nothing happens and I have to restart m PuTTY session to access the Pi again. Also, running any X applications from the command line (such as 'midori &') gives me this error:

Code: Select all

Midori - Cannot open display:
I have the XMing X Server software currently running an X Server on my PC (as per the instructions here), so I don't see any reason this isn't working. Please advise me on what do to in order for this to work.
...
FWIW some example screenshots of (parts of my) PuTTy setup that enable X11 forwarding etc. can be found at http://www.cpmspectrepi.webspace.virgin ... aspPi.html. For a "startx-like" environment/screen you need to have a VNC server (eg. tightvnc) running on the Pi and a VNC clent on your PC. Examples of this can be found in the Wiki.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B, B+, and a A+) but Buster on the P3B+, P4B's & P400. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

dangertux
Posts: 12
Joined: Sun May 26, 2013 11:13 pm

Re: Startx over SSH

Mon May 27, 2013 12:09 am

FTrevorGowen wrote:
WJacobC wrote: ...
The problem is, I don't have an HDMI monitor, so I decided to run the Pi from my main PC over SSH. I'm using PuTTY on my Windows 8 PC, and everything is working fine in the command line interface. But when I run 'startx', nothing happens and I have to restart m PuTTY session to access the Pi again. Also, running any X applications from the command line (such as 'midori &') gives me this error:

Code: Select all

Midori - Cannot open display:
I have the XMing X Server software currently running an X Server on my PC (as per the instructions here), so I don't see any reason this isn't working. Please advise me on what do to in order for this to work.
...
FWIW some example screenshots of (parts of my) PuTTy setup that enable X11 forwarding etc. can be found at http://www.cpmspectrepi.webspace.virgin ... aspPi.html. For a "startx-like" environment/screen you need to have a VNC server (eg. tightvnc) running on the Pi and a VNC clent on your PC. Examples of this can be found in the Wiki.
Trev.

Ewww -- yeah I didn't catch the OP said he had Putty. I've NEVER had a good experience with XForwarding in PuTTy. If you can, on the machine you're trying to SSH from it might be helpful to build a linux VM to ssh from, the native Linux environment will look MUCH better in my experience. If not VNC might be the way to go, but for security reasons you might want to tunnel it over SSH

klricks
Posts: 8474
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA

Re: Startx over SSH

Mon May 27, 2013 12:49 am

WJacobC wrote:Thanks for your reply Klricks. I'll definitely check that out.
klricks wrote:You cannot run startx or any GUI applications through SSH.
This article and other threads here seem to disagree with your statement. I'm not sure whether it is possible or not, but these guys seem to have figured out how to do it. Any ideas anyone?
I assumed you were using the basic SSH. I have used Xserver on MobaXterm to do what you are asking but it was so slow and sluggish it was nearly unusable. RDP is quite a bit better but still slow. Note the MobaXterm can do regular SSH and RDP as well as XServer over SSH.
http://mobaxterm.mobatek.net/
Unless specified otherwise my response is based on the latest and fully updated RPi OS Bullseye w/ Desktop OS.

SimonSmall
Posts: 220
Joined: Tue Oct 09, 2012 8:13 pm

Re: Startx over SSH

Mon May 27, 2013 8:37 am

You can run X programs using X11 forwarding over SSH, not a problem to set up at all, and it works very well. In fact, if you are running multiple monitors on your PC you can put Pi windows across the monitors. You cannot run startx to get the desktop; for that you need VNC, RDP or another connection.

Start the Putty program on your PC. Before connecting, select the Connection / SSH / X11 options on the left menu, tick the "Enable X11 forwarding" box and set the "X display location" to localhost:0.0 - now connect and login. Make sure Xming is running on the PC, then type the X program followed by "&"; this runs the program in a background process, returning control to the command line so you can launch more programs.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Startx over SSH

Mon May 27, 2013 9:48 am

StartX can only run locally on the Pi it does not provide X11 access remotely for that you'll need software i.e. Starnet or Xming with Putty (and X11 forwarding enabled) or MobaXterm which has built in SSH/X11 support.
Once you have logged in via SSH then use lxsession & to load the desktop or alternatively start your GUI programs individually from the console.

Richard S.

sdjf
Posts: 1397
Joined: Fri Mar 16, 2012 5:20 am
Location: California

Re: Startx over SSH

Mon May 27, 2013 1:59 pm

I can confirm that it is possible to run GUI apps without an HDMI or other regular monitor for the Pi. I have no monitor and run GUI apps, but use VNC. I set DISPLAY variable in my .bashrc so I do not have to tell every GUI I start, where to send their displays.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

User avatar
WJacobC
Posts: 12
Joined: Wed Dec 26, 2012 1:48 am

Re: Startx over SSH

Wed May 29, 2013 12:29 am

SimonSmall wrote:You can run X programs using X11 forwarding over SSH, not a problem to set up at all, and it works very well. In fact, if you are running multiple monitors on your PC you can put Pi windows across the monitors. You cannot run startx to get the desktop; for that you need VNC, RDP or another connection.

Start the Putty program on your PC. Before connecting, select the Connection / SSH / X11 options on the left menu, tick the "Enable X11 forwarding" box and set the "X display location" to localhost:0.0 - now connect and login. Make sure Xming is running on the PC, then type the X program followed by "&"; this runs the program in a background process, returning control to the command line so you can launch more programs.
This is what I've been trying, and I get the cannot open display error. My 'X Display Location is set to Localhost:0, so I'll retry it tonight using your settings.

I first installed PuTTY, then downloaded XMing. Any use in removing both then starting with just XMing? (Since it had an option to install a special version of PuTTY with it.)

Thanks for all the suggestions so far guys.
Twitter @WJacobC | WJacobC.com

SimonSmall
Posts: 220
Joined: Tue Oct 09, 2012 8:13 pm

Re: Startx over SSH

Wed May 29, 2013 7:14 pm

Try with "localhost:0.0", lower case, two zeros

User avatar
WJacobC
Posts: 12
Joined: Wed Dec 26, 2012 1:48 am

Re: Startx over SSH

Wed May 29, 2013 7:50 pm

Aha! That worked. Thanks SimonSmall. I guess we can consider this a resolved question :) Thanks everybody.
Twitter @WJacobC | WJacobC.com

tonyAC
Posts: 3
Joined: Mon Nov 27, 2017 8:00 pm

Re: Startx over SSH

Mon Nov 27, 2017 8:08 pm

hi
same error "startx"
should we connet the raspberry pi to the internet to boot the device? or isn't necessary ?
thx for help

Ekevoo
Posts: 1
Joined: Sun Apr 23, 2017 2:33 am

Re: Startx over SSH

Sat Jun 22, 2019 5:01 am

Hi, I have a bit of a different use case but I would definitely describe it as "startx over SSH" so I'm going to use this thread anyway.

My Pi is connected via HDMI to a TV. I do not have a keyboard that can be connected to it. I want to start X and also start Firefox in it so it'll just display a page and I can forget about it.

First, edit /etc/X11/Xwrapper.config and set allowed_users=anyone
Bam, startx works!

Put this line in .startx… adapt to your desired URL and monitor size of course.
firefox-esr -private-window "https://youtu.be/Kob0G2hE8IY" -geometry 1920x1080+0+0

arisw
Posts: 7
Joined: Tue Aug 11, 2015 5:13 am

Re: Startx over SSH

Mon Nov 25, 2019 2:51 pm

Ekevoo wrote:
Sat Jun 22, 2019 5:01 am
First, edit /etc/X11/Xwrapper.config and set allowed_users=anyone
Did you mean anybody ?
https://manpages.debian.org/stretch/xse ... .5.en.html

Return to “Beginners”