X windows session over ssh on Mac/Linux


22 posts
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: 83
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.
Posts: 37
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
Posts: 37
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: 2193
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