Design a site like this with WordPress.com
Get started

Running GUI applications over SSH on a Raspberry Pi

Sometimes you have a RPi attached to a screen, but no keyboard or mouse attached and want to run GUI applications on it via SSH. This will also let you cross-compile RPi applications on a development machine and test them on the real machine.


Prepare the RPi for ssh access

To enable SSH access on a freshly installed RPi, put a file called ssh into the boot directory of the SD cards before booting up the first time. To enable WiFi you need to add a wpa_supplicant.conf file.

Set up the RPi

To log into the remote RPi wait for it to come online and then run:

ssh <PI_ADDRESS> -l <PI_USER>

where PI_ADDRESS is the IP adress on your network and the PI_USER is usually “pi”.
Now make sure your run “raspi-config” and set up your locale, keyboard layout etc. properly.
To run a GUI application you will need an X-server. If you have a full-blown desktop installation it is already installed, put if you use e.g. the “Lite” version of Raspbian you need to install the necessary packages:

sudo apt install --no-install-recommends xserver-xorg x11-xserver-utils xinit

If you now run applications remotely you might get some errors:

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

and / or:

xf86OpenConsole: Cannot open ... console ... (Permission denied)

To fix that, edit /etc/X11/Xwrapper.config and change the line “allowed_users=console” to:

allowed_users=anybody
needs_root_rights=yes

Now you should be able to run graphical applications using:

xinit <PROGRAM>

Xinit docs are here. You can also use startx instead. All xserver options are here.
If you want to run your application on startup, see this. If you want to set a webbrowser kiosk and run chromium, see this tutorial.

Advertisement

Published by HorstBaerbel

Software developer by trade and interest, but I venture into the electronics- and diy-world from time to time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: