X windows session over ssh on Mac/Linux


28 posts   Page 1 of 2   1, 2
by higwoth1 » Mon May 28, 2012 3:47 am
Hi,

I'm sure everyone knows how to do this, but I see a lot of people running tightvncserver to run an X session remotely whereas running X over ssh is much more efficient as the poor old Pi doesn't have to do as much compression and/or drawing the screen.

On a mac (and linux) it's just a matter of running the command
Code: Select all
ssh -X pi@YOUR_PI_IP_ADDR

Your Pies(?) IP can be seen by typing
Code: Select all
ifconfig
OUTPUT:eth0      Link encap:Ethernet  HWaddr b8:27:eb:bc:d7:79 
          inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0

Once logged into your Pi, you will notice the usual pi@raspberrypi prompt, plus an X session will start on your Mac. Running any X windows program will display the results on the Mac.

Try
Code: Select all
 xeyes

To run a complete session, type
Code: Select all
lxsession
into the ssh window to start a LXDE session on the Mac (but running on the Pi).

Sound works (it comes out of headphone socket) if you do a
Code: Select all
sudo modprobe snd_bcm2835


For best results make sure to change prefs for X11 - output->fullscreen, otherwise it can a bit muddly, or just move to a seperate clear desktop (mac) and minimise the original terminal (don't close it or this will logout from the pi)

To quit, it's best just to do a 'sudo reboot' otherwise things get confusing, though you can ctrl-c the original terminal to terminate the lxsession.

You will have to setup ssh on the pi :-

Code: Select all
   cd  /boot
   sudo mv boot_enable_ssh.rc boot.rc

Now reboot pi and ssh should work.

If anyone else can confirm this works on their Debian squeeze 19-04-2012, on a virgin install, it would be useful. I may have inadvertantly setup a package to facilitate this, but it should work straight out of the pi-box.

I think there is a version of X for windows, but as usual you'll have to jump through a lot more hoops.
Posts: 26
Joined: Sat May 26, 2012 1:27 am
by cmatthews » Mon May 28, 2012 6:59 am
This also works for me and I would agree that it is a better solution than VNC. I don't think it needs any extra packages.
www.mydominion.co.uk
Posts: 84
Joined: Fri May 11, 2012 9:05 pm
Location: Wirral, UK
by higwoth1 » Mon May 28, 2012 1:05 pm
Ok, that's good.

I wish I could edit that post because I made an error which limits a few things, such as remembering settings and the 'Other' menu.

Instead of
Code: Select all
lxsession


Type
Code: Select all
/etc/X11/Xsession


Probably not the ideal way of doing this, hopefully someone with more knowledge of X will be along shortly.
Posts: 26
Joined: Sat May 26, 2012 1:27 am
by slacker » Wed May 30, 2012 6:45 pm
Just tried this and it works on a fresh install of Debian squeeze 19-04-2012. On the local machine I had to do "xhost +" to allow the pi to connect to the x server, may or may not be needed depending on how X is set up on the local machine.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by XavM » Thu Jun 14, 2012 7:24 am
it works like a charm

Conf :

- Fresh Debian Squeeze image with no installed package but updated to the latest (as of June 14) kernel and firmwares via rpi-update.
- OSX 10.7.5 with Standard X11 "XQuartz 2.6.4 (xorg-server 1.10.6)"
- "ssh -X pi@MyPiHostIP" then "pi@raspberrypi:~$ /etc/X11/Xsession" to launch the session from the OSX terminal

And of course it just works as well from iPad using iSSH or any client supporting X11
Posts: 35
Joined: Thu May 31, 2012 11:29 pm
by alecthegeek » Thu Jun 14, 2012 7:31 am
I'm using the new wheezy testing image and I've hit a couple of snags.

1) The LXDE task panel along the bottom no longer displays.
2) Scratch will not display. X Application window comes up bit is empty and unresponsive.
--
Alec Clews <alec.clews@gmail.com>
http://about.me/alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
by apt105 » Mon Jun 25, 2012 7:48 pm
Is there any way to get this running in a new virtual window? Ie have my local gnome running on F7 and Pi's LXDE running on F8?
Posts: 1
Joined: Mon Jun 25, 2012 7:47 pm
by alecthegeek » Tue Jun 26, 2012 12:52 am
I'm running OS X as my X server so it does not quite work as Linux.

I have tried the X server in both full screen and windowed mode. No difference
--
Alec Clews <alec.clews@gmail.com>
http://about.me/alecthegeek
Posts: 38
Joined: Mon Aug 08, 2011 3:11 am
Location: Melbourne, Australia
by AndrewS » Tue Jun 26, 2012 8:38 am
apt105 wrote:Is there any way to get this running in a new virtual window? Ie have my local gnome running on F7 and Pi's LXDE running on F8?

viewtopic.php?f=29&t=8455 8-)
User avatar
Posts: 3626
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
by SDC » Fri Aug 03, 2012 2:13 am
XavM wrote:it works like a charm
...

And of course it just works as well from iPad using iSSH or any client supporting X11


Yes. I've had success with iSSH on the iPad.
--- SDC
Posts: 6
Joined: Sat Jul 28, 2012 11:09 pm
by alexjj » Fri Aug 03, 2012 11:46 am
SDC wrote:
XavM wrote:it works like a charm
...

And of course it just works as well from iPad using iSSH or any client supporting X11


Yes. I've had success with iSSH on the iPad.


Would you mind explaining how to get it working with iSSH?
I can connect to rpi, type
Code: Select all
/etc/X11/Xsession
but the x display is just greyed out.
Posts: 15
Joined: Sun Feb 05, 2012 11:42 am
by SDC » Fri Aug 03, 2012 12:34 pm
alexjj wrote:
SDC wrote:
XavM wrote:it works like a charm
...

And of course it just works as well from iPad using iSSH or any client supporting X11


Yes. I've had success with iSSH on the iPad.


Would you mind explaining how to get it working with iSSH?
I can connect to rpi, type
Code: Select all
/etc/X11/Xsession
but the x display is just greyed out.


No problem:

From the x-term (text) window in iSSH, (after logging into RPi remotely) type
Code: Select all
export DISPLAY=xx.xx.xx.xx:y

where the IP address and Display are the value shown on the x-window panel in iSSH.  (e.g. 108.168.0.101:0)

Then, in the x-term panel of iSSH, run an x window program, e.g.:
Code: Select all
scratch &

or 
Code: Select all
leafpad &


move to the x-window panel and there it is!

If that doesn't work, still, you may need to enable X11 forwarding on the RPi. (see known issues for iSSH at 
http://www.zinger-soft.com/support_e_1.html )

eg:
Code: Select all
sudo nano /etc/ssh/ssh_config


change line that reads:
Code: Select all
#X11Forwarding No

to 'yes'.

you'll need to reboot.
--- SDC
Posts: 6
Joined: Sat Jul 28, 2012 11:09 pm
by mwhite41 » Mon Sep 24, 2012 6:07 am
Thanks for the information on this thread. I've just tried it (Xquartz and default Rasbian distro) and the desktop generally works fine.

One comment though: the Rasberry Pi's desktop icons aren't clickable. I can run Midori etc from the menu successfully, but clicking on the Pi desktop icons just takes the OS X focus back to Finder.

This sounds like an Xquartz issue; any ideas?

Thanks all!

Mark
Posts: 2
Joined: Mon Sep 17, 2012 6:06 am
by stonehippo » Sat Oct 20, 2012 5:33 am
mwhite41 wrote:One comment though: the Rasberry Pi's desktop icons aren't clickable. I can run Midori etc from the menu successfully, but clicking on the Pi desktop icons just takes the OS X focus back to Finder.

This sounds like an Xquartz issue; any ideas?


Mark,

You need to enable full-screen mode in XQuartz. Command-, to open preferences, then select Full-screen Mode on the Output tab. Your LXDE window will probably disappear; use Command-Option-A to toggle the display of the new full-screen view.

G
Posts: 1
Joined: Sat Oct 20, 2012 5:27 am
by MarkFromNJ » Thu Nov 01, 2012 10:08 am
I can connect, and get the RPi display on my Mac. Icons are clickable. But I cannot get the task bar to display. Any ideas?
OS X 10.7.5
XQuartz 2.7.4 - Prefs for full screen
2012-10-28-wheezy-raspbian - virgin except changes to configure wifi and regenerate ssh keys

Thanks in advance!
-Mark
Posts: 1
Joined: Thu Nov 01, 2012 10:02 am
by Rickrcomm » Mon Nov 05, 2012 9:02 pm
I am joining those having difficulty getting a RaspPi XWindow to display on my Mac. Mountain Lion, XQuartz. Occidentalis v.2.

I can ssh into the RP with ssh -X pi@<IP> from the XQuartz xterm, login. But when I try scratch&, I get:

Executing: /usr/lib/squeak/4.4.7-2357/squeakvm -encoding UTF-8 -vm-display-x11 -xshm /
-plugins /usr/lib/scratch/plugins/:/usr/lib/squeak/4.4.7-2357/ -vm-sound-alsa /
/usr/share/scratch/Scratch.image
No protocol specified
Could not open display `(null)'.

I tried export DISPLAY=<MAC IP>:0.

I set X11Forward yes in ssh_config.

When I change the initial ssh command from the Mac to ssh -Y pi@<RPi IP>, I get the Adafruit logo splashed across both the monitors on my Mac with my Mac dock on top of that.

Help!

Thanks,
Rick
Posts: 2
Joined: Mon Nov 05, 2012 8:45 pm
by novus » Mon Nov 12, 2012 3:24 am
What if I want to SSH into my RPi, then do something like start Mplayer and watch a movie, but on the monitor the RPi is connected to? I've wondered this before with SSH, but now I'm even more curious because my RPi just came in and I have no keyboard! :(
Posts: 2
Joined: Mon Nov 12, 2012 1:52 am
by fdion » Mon Nov 12, 2012 10:49 pm
novus wrote:What if I want to SSH into my RPi, then do something like start Mplayer and watch a movie, but on the monitor the RPi is connected to? I've wondered this before with SSH, but now I'm even more curious because my RPi just came in and I have no keyboard! :(


The proper way to do this is to set up your user to auto login, then set up mplayer to start up from the .bashrc, in slave mode, in the background (&). You can then send commands from your PC over ssh through the slave mechanism you set up (such as a pipe or fifo).

If you need more detail, I'll start a different thread. This one is for XWindows over ssh (aka, the sidekick mode: http://www.raspberry-python.blogspot.com/2012/09/sidekick.html )

François
Francois
http://raspberry-python.blogspot.com - @f_dion
User avatar
Posts: 305
Joined: Sun Sep 16, 2012 2:33 pm
Location: North Carolina, USA
by phbcanada » Thu Apr 04, 2013 2:30 pm
This doesn't work for me from OSX 10.8.3. When I try to start a session, nothing happens. :(

What am I missing?
Thanks
User avatar
Posts: 13
Joined: Tue Dec 11, 2012 1:16 pm
by Drew » Thu Apr 04, 2013 2:56 pm
phbcanada wrote:What am I missing?
Thanks


Maybe the OSX developer tools with X11?
It would also help if you gave us some idea of the result too, what does ssh say when left to timeout?
Can you even ssh into the pi without the X window session (remove -X)? ssh needs to work before you try forwarding sessions to things that may not be installed.

You can also add -vv to the ssh to see more debug info, more v's = more debug info.

Also to RTFM: 'man ssh'
Posts: 39
Joined: Fri Jan 20, 2012 3:50 am
by andrewr » Sun Dec 22, 2013 4:37 pm
This didn't work for me on mac OSX 10.8.2. No errors, nothing.

Installed XQuartz http://xquartz.macosforge.org/ logged out and back and works excellent
Posts: 4
Joined: Sat Dec 21, 2013 4:48 pm
by grahambb » Wed Dec 25, 2013 12:49 am
Installing (and running Quartz) (on OSX Mavericks 10.9.1) worked for me with the ssh -X notation. Ran well, though somewhat slowly!

One issue is that X comes up under all my windows. Those OSX windows do not go into the background, nor can the Pi graphical icons on the desktop be clicked. Using the menu buttons to run e.g. Midori DOES work.

Cheers

Graham
Posts: 6
Joined: Fri Oct 11, 2013 9:06 pm
Location: Oakland, California
by lanwarrior » Sun Sep 07, 2014 7:50 pm
I have Maverick (10.9.1). My Pi B+ is running the latest Wheezy and I can do "startx" directly (not through SSH). I can also SSH to my Pi (pi@machinename.local). I setup SSH public/private encryption so I can SSH without password. I have XQuartz installed on my Mac.

From either Mac Terminal or XQuartz, I typed:

Code: Select all
ssh -X machinename.local -l pi


I logged in just fine.. but no X session is shown. XQuartz did started, but no X Windows open. Just the terminal showing I logged in.

I tried typing "startx" from the Terminal / XQuart and just got this error

Code: Select all
X.Org X Server 1.12.4
Release Date: 2012-08-27
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.0-2-mx5 armv7l Debian
Current Operating System: Linux TimePi 3.12.26+ #704 PREEMPT Wed Aug 20 22:35:11 BST 2014 armv6l
Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x10 bcm2708.serial=0xa9e38505 smsc95xx.macaddr=B8:27:EB:E3:85:05 bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Build Date: 18 December 2013  05:20:52PM
xorg-server 2:1.12.4-6+deb7u2 (Julien Cristau <jcristau@debian.org>)
Current version of pixman: 0.29.3
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sun Sep  7 12:45:22 2014
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
FATAL: Module g2d_23 not found.
^Cxinit: connection to X server lost
Server terminated successfully (0). Closing log file.
xinit: unexpected signal 2


Am I missing something? I did enable X11 forwarding in ssh_config AND sshd_config.
Posts: 41
Joined: Fri Aug 22, 2014 6:05 am
Location: Somewhere in the you-es-a
by B.Goode » Sun Sep 07, 2014 9:14 pm
lanwarrior wrote:Am I missing something? I did enable X11 forwarding in ssh_config AND sshd_config.


You haven't done anything to get a session displayed on the mac.

In the original post at the top of this thread it says

Once logged into your Pi, you will notice the usual pi@raspberrypi prompt, plus an X session will start on your Mac. Running any X windows program will display the results on the Mac.



To run a complete session, type


lxsession

into the ssh window to start a LXDE session on the Mac (but running on the Pi).


Don't try to use 'startx' - that is only applicable to using a directly-connected graphical display, and is not useful for your remotely-connected scenario.
Posts: 421
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK
by socialdefect » Sun Sep 07, 2014 9:19 pm
A while ago a friend of mine was having trouble with his dad's pc but he didn't have the time to travel 20km to fix it. His dad was also behind a firewall and had no remote applications installed. The easiest solution I knew of was to set-up a ssh tunnel to my VPS from where it was then possible to connect using ssh. Since my friend is not really an ssh type of guy I ended up writing a simple script to simplify running an X desktop in a nested window. The script uses Xephyr for displaying the X desktop.

The script is called RSSHDP (Remote SSH Desktop) and is very easy to use, just download it, Install dependencies (you will be prompted if any are missing), create a config file from the example given in the README file and execute.

Since I got some requests for a GUI application for setting up the tunnel on the client-side I got started on that yesterday and committed the first GUI to Github today. the GUI does nothing more then help you set-up a reverse ssh tunnel with port forwarding and might even be more work than typing the command yourself, but if you don't like the terminal you might like it.

== If it's not broke... I'm not done fixing it! ==
User avatar
Posts: 105
Joined: Mon Jun 25, 2012 9:02 pm
Location: Tilburg, the Netherlands