SSH - addycakes/Domotics GitHub Wiki

All the devices communicate via ssh. The iOS device talks to a particular pi through a forwarded port. That pi then relays commands over LAN to the appropriate arduino or pi to carry them out. Raspberrypi.org has a straight forward tutorial on creating keys for ssh, which is strongly recommended if you plan to port forward for this purpose.

This iOS library for ssh worked flawlessly to sends commands, download files, and upload files to the raspberry pi. Although, I was unable to get a pseudo terminal working in the app

Here is a code sample for an adapter class that wraps around the NMSSH library. The adapter formats requests properly for the NMSSH library methods and for the terminal receiving the requests.

To send commands between the pis and arduinos the subprocess libraries can be used easily enough like this:

import subprocess

sshHost = ip_address_of_host
sshCommand = terminal_formated_string

#send the command via SSH 
ssh = subprocess.Popen(["ssh", "%s" % sshHost, sshCommand],  #may need to specify key with "-i", "path_to_key")
                   shell=False,
                   stdout=subprocess.PIPE,
                   stderr=subprocess.PIPE)
⚠️ **GitHub.com Fallback** ⚠️