I've been trying to connect to raspberry pi over ssh on a mac and then open the desktop using startx. I know on a windows you can use putty and xming but both of those are windows programs only. Is there a way that I your x11 forwarding on mac when using ssh with my pi? I already know how to ssh using the terminal and have also tried Spackle. Any suggestions will be appreciated.

4 Answers 4


I had the same problem, and have a solution working now, but it needs a little refining (I can't get it to run in anything other than full screen).

My Mac is an iMac 27in, and I'm using a Pi model 2 with the latest Raspbian image. I have Quartz and thus X11 installed on the iMac because I need this for the Dia program. From the iMac terminal, I ssh to the Pi with the -X option (so ssh -X [email protected]).

After entering the password, I get several messages including one about auth key data, but I just ignore these for the moment. Once at the prompt on the Pi, as user pi, I just enter lxsession (and again, some messages go past) then the big Raspberry appears in the middle of my screen and I have the Raspberry Pi's desktop. I need to use "cmd+opt+A" to get back to the OSX desktop, and I'm still working on how to get a more "manageable" window, but it most certainly works !

My motivation for doing this was to get it working WITHOUT any additional software, and it is working well for me, even though most of my time is spent in a terminal.

Another option that also works well is to install xrdp on the Pi, then use the Microsoft Remote Desktop app from the App Store (I know, it sounds strange) but this also works really well, but it does mean installing extra software.

My OSX has just been upgraded to El Capitan, but I did most of this originally on Yosemite. Good luck Simon


If you want to display X11 apps on your Mac desktop, you don't run startx from the pi - that will attempt to start it on the pi's screen. Instead, run an X11 server on your Mac, configured to allow remote connections. Then, on the Pi, set your DISPLAY environment variable to point to the Mac's server.

In my case (macOS Sierra 10.12.6), I downloaded and installed XQuartz (version 2.7.11 (xorg-server 1.18.4)). Then, in the X11 Preferences, on the Security tab, check the "Allow connections from network clients" box. Finally, issue an appropriate xhost command to allow your pi to connect (xhost + will work fine if you trust everybody on your LAN - probably OK at home but bad for any kind of public network).

At this point, you can ssh to the pi as you always do, without any special kind of X11 forwarding. In there, set the DISPLAY environment variable to point to your Mac's X server. For example, if the Mac's IP address is and the X server is display 0, you would export DISPLAY=

With this done, X11 apps on the pi will send their output to the Mac.

If you log in to the pi from multiple computers, you can add code to your .bashrc (or .login if you use tcsh) to set DISPLAY based on the IP address you logged in from. Or you can just use the -Y parameter of ssh.

Of course, the XQuartz app must be running whenever you try to log in. Otherwise, the X11 communication won't have anywhere to go and you won't see any graphics.


X11 is no longer included with OS X. XQuartz libraries are available, but I know of no tools which use these for ssh.

I suggest you install VNC on the Pi (I use tightvncserver) and access from the Mac like

open vnc://[email protected]:5901
  • 1
    Thanks for the help. I so have X11 downloaded on my mac. I was trying to avoid vnc. Thanks once again for your help. Commented Sep 13, 2015 at 2:20
  • 1
    If you are worried about VNC security, then port forwarding can be used to send the VNC traffic from localhost (the Raspberry Pi) to your OSX session. VNC is a lighter weight solution than opening a ssh connection and typing startx, since the former sends an image whereas the latter passes a lot more information over the network.
    – W. H. Bell
    Commented Sep 16, 2015 at 11:04
  • Check out this page: elinux.org/RPi_Remote_Access#Running_a_remote_GUI Commented Dec 26, 2015 at 13:51
  • You don't need any tools that use XQuartz for ssh. Just run XQuartz, which will open an xterm window. Then type in your ssh command (with -Y) from there. Or SSH from any other window and set your DISPLAY variable appropriately. VNC works great, but it consumes display resources on the Pi, which you may not want to do if you don't have to.
    – David C.
    Commented Mar 13, 2023 at 20:01

You don't have to set the DISPLAY variable if you use xfowarding via SSH by adding -Y to your ssh command on the Mac!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.