Program remotely on Raspberry Pi

Major advantage of such tiny computers as Raspberry Pi (RPi) is ability to work on small autonomous platforms like mobile robots. However computer, moving with a robot, is a challenge as well – during development it is not easy to change the code. Remote connection to the computer via SSH or VNC, using Wi-Fi, might help in such cases.

Read also Connect to network Raspberry Pi with Ubuntu

Connection IP address

RPi should be connected to network via wired or wireless connection – with network cable or Wi-FI USB dongle or adapter (Raspberry Pi 3 has the Wi-FI adapter on-board). IP address is needed to connect remotely over SSH or VNC.

There are few ways to get the IP address (including scanner utils like nmap)

Command ifconfig



Admin-console of the router – usually in the section “Attached devices”. The admin-console can be opened within web-browser by address or (the address may be different for some routers and its settings). Connection can be in “Wered Devices” section – when the RPi connected with network cable, or in “Wireless Devices” section – in case of connection by Wi-FI


In the example above the IP address for connection to RPi remotely is

Connection over SSH

Usually operation systems, installed on RPi, have SSH server installed and running by default. Otherwise it can be installed manually. E.g. install OpenSSH server

sudo apt-get install openssh-server

After installation – check the status of the service

sudo service ssh status


Connection from the remote computer is performed with SSH-client. Install OpenSSH client

sudo apt-get install openssh-client

Connect to the RPi from remote computer via SSH. In this example – user1 is a user existing in the operation system of RPi (usually one created during initial system setup)

ssh user1@

During first connection the ssh-client requires to accept security-key. Each connection also requires to enter the password of the user on the computer where ssh-client is connecting (not the password of the local user)


Next connection requires only a password


In this example, just coincidently, users on computers rpi (Raspberry Pi) and comp1 (some local PC) have the same names: user1. Example of connection with another user, existing in the system on RPi – user2

ssh user2@


Connection over VNC

VNC server is not such often installed by default. Install the TightVNC server

sudo apt-get install tightvncserver

Start of VNC server with minimum options. “:1” is a display number (do not use “-0” as it is used by X session by default). The password, required during the first start of the VNC server, is specifically for the VNC connection (this is not a user password!)

vncserver :1


On the client computer – install a VNC client (or VNC viewer). Install the TightVNC client

sudo apt-get install tightvncclient

Connect remotely over VNC to RPi with VNC server started on display 1



As a result – the new windows is opened with the desktop of system on RPi


There are options of vnc-client affecting quality and performance of VNC session

vncviewer -depth 8 -compresslevel 9 -quality 0
vncviewer -depth 32 -compresslevel 0 -quality 9
vncviewer -depth 8 -compresslevel 5 -quality 5

Raspberry-Pi-CLion069 Raspberry-Pi-CLion070 Raspberry-Pi-CLion071

Resolution and color depth of the desktop can be specified when VNC server is started or within its parameters in settings files

vncserver -geometry 320x240 -depth 16 :1
vncserver -geometry 1024x800 -depth 8 :1

Raspberry-Pi-CLion072 Raspberry-Pi-CLion073

VNC server can be stopped manually – for each particular display

vncserver -kill :1


VNC server can be started automatically on boot.

VNC server can be used even when Display Manager is not started – this saves resources when a user connect to the computer mostly remotely. In Ubuntu Mate special command enables and disables Display Manager for next boot

sudo graphical enable
sudo graphical disable

To start GUI manually when it was not started at boot – execute the command lightdm and switch to GUI pressing Ctrl+Alt+F7

sudo lightdm

Program remotely

Install on RPi software development environment (e.g. Eclipse) or use existing – installed by default.

Program via VNC

On RPi start VNC-server (if not started) with preferred resolution (-geometry WxH) and color depth (-depth D) and connect to it remotely from PC with VNC-client. Use the favorite IDE in the remove desktop or run programs with GUI

  • Pros
    • all GUI applications are available
  • Cons
    • not used GUI forms consume resources
    • not easy (or even not possible) to use keyboard shortcuts

Connect to RPi via VNC-client


On the remove display – start the preferred IDE


Program via SSH with X11-Forwarding

On RPi start SSH-server (if not started) and connect to it remotely from PC with SSH-client. Use the text-based editors (e.g. vim) in the remote terminal or run programs without GUI.

Options -X and -Y

  • Pros
    • all GUI applications are available
  • Cons
    • not used GUI forms consume resources
    • not easy (or even not possible) to use keyboard shortcuts

Connect to RPi via SSH with option -X or -Y (depending on trust requirements) – both for X11-Forwarding; optionally -C  – which turns on compression of transferred data

ssh -X -C user1@

Run the preferred IDE. E.g. Eclipse


In some cases IDE can be started under sudo permits – this amight be required for access to some hardware

sudo eclipse


Some programs running via SSH and X11-Forwarding can hang UI of the computer running SSH-client – mouse moves but its clicks of keyboard key-presses do not affect UI for 1-2 minutes.



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.