Controlling the Pi Rover over SSH


We have seen how to control the Pi Rover over HTTP. However, you may find it a bit of an overkill to install a webserver bundled with PHP just to control the motors. A leaner alternative would be to remotely execute commands over SSH. We assume a Unix-like OS on which you can run the SSH client from the command line (e.g. Linux, OS X, Windows with CygWin).

Set up a password-less login

Of course, SSH needs to be enabled on the Raspberry Pi. You can do this using raspi-config:

sudo raspi-config

Navigate to SSH and enable the server.

Once you have logged in successfully from the client system generate the public and private RSA keys:


You can use the default values and leave the passphrase empty for a completely password-less login.

Copy the new key to the Raspberry Pi. In this example the Pi is at IP and the remote user is ‘pi’.

ssh-copy-id pi@

Controller scripts

On the Raspberry Pi a simple Python script sends commands and data (taken from the command line) to the motor controller:

A shell script that we will call over SSH translates movement commands into the arguments taken by the Python script:

Client-side scripting

In our client script, instead of posting a payload over HTTP, we simply call the shell script with the appropriate arguments:

def send():
        Popen(['ssh', 'pi@', '/home/pi/ %s %s' % (command_data.command,])

Leave a Reply