I would like to send a command with some predetermined number of arguments to a Raspberry Pi and get the output back from it. I was thinking of using restricted ssh key but was wondering if that is the best way. This command doesn't need to be sent frequently, maybe it can be sent every 10 minutes. Also the string that the command returns is about 100 characters. I'm looking for a secure and easy to maintain way to achieve this. In terms of security I think this is good but I think setting this up is a bit tedious. Is there any better way?

  • 3
    There isn't enough information here to really help. We need to know a lot more about how the devices are connected (e.g. are they all on the same network, are they all behind NAT gateways). Also have you looked at existing IoT messaging systems (e.g. AWS Iot, IBM Watson IoT)?
    – hardillb
    Apr 11 '19 at 12:06
  • I was thinking of the leanest way possible, so just port forwarding. I was also thinking of an ordinary home application so that would not be behind NAT gateways, I guess. So I haven't checked AWS IoT or IBM Watson IoT because that would involve more things to do than just port forwarding.
    – Vasco
    Apr 12 '19 at 6:32
  • 1
    Home networks are nearly always behind NAT gateways and the offerings from AWS & IBM do not need any port forwarding
    – hardillb
    Apr 12 '19 at 6:35
  • 1
    It's a pity that this question is closed, because it's an important one that when implemented incorrectly gives IoT a bad reputation for security. The short answer is your Pi should not open any ports, ever. Use a message broker (or message broker oriented IoT platform) that implements mqtt or similar protocols. For a longer answer an reasons look for “Service Assisted Communication for Connected Devices" Apr 26 '19 at 12:15