User avatar
skywatch
Posts: 46
Joined: Tue May 21, 2013 8:17 pm

Pi-toPi communication via SSH possible?

Sun Feb 21, 2016 7:45 pm

Hi,

I would like to know if it is possible to have a pi automatically SEND a command over SSH to another machine when a certain condition occurs.
Lets say if the temperature gets too hot then the pi can send a shutdown signal to a heater or server via an SSH link.

I would assume it can be done, but how would you do this in practice? (I know about the measurement side, it's just how to send a given SSH command from the pi I am stuck with). :?:

Thanks if you can help!

Skywatch.

User avatar
joan
Posts: 14884
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pi-toPi communication via SSH possible?

Sun Feb 21, 2016 7:51 pm

ssh otherpi command

where otherpi is the host name or IP address and command should be quoted if it has spaces.

This assumes you have the needed keys at otherpi to allow auto log in.

User avatar
skywatch
Posts: 46
Joined: Tue May 21, 2013 8:17 pm

Re: Pi-toPi communication via SSH possible?

Sun Feb 21, 2016 8:00 pm

So a simple bash/cron script is all I need then?

So it would be ......

SSH 192.168.x.x "sudo poweroff"

Thank you! :D

Return to “General programming discussion”