Sample Header Ad - 728x90

Linux motion user - run it as ssh key as pi to remote server

2 votes
2 answers
697 views
This question is related to the [two](https://unix.stackexchange.com/questions/112087/broadcast-or-send-machine-readable-code-to-ssh-clients) [other](https://unix.stackexchange.com/questions/114080/run-linux-motion-app-as-user) questions I had earlier, about enabling Raspberry Pi to act as a motion sensor that will try to ssh into a more powerful server when it detects motion (the more power server will then do additional processing via a script). So here's what I did: - On the Raspberry Pi, I installed Linux motion app - I also used ssh-keygen on the Raspberry Pi and then using ssh-copy-id copies public keys to the more power server, so that the Raspberry Pi can ssh to the server without having to type in the password. - On the motion.conf file, there's a line for on_motion_detected event for when the motion is detected by Raspberry Pi, on that line, I have something like: >ssh user@more.powerful.server '/exec/some/script/here' - But the script on the more powerful server is never executed because the motion daemon is running as user 'motion', rather than the user (pi) that did the ssh-keygen that the remote server accepts. I know this because: - If I change the on_motion_detected command to: >on_motion_detected echo hello_world | wall this command gets executed and I see it on all the terminals that are ssh'd into the Raspberry Pi - Or, if instead of on the on_motion_detected line, I simply run ssh user@more.power.server '/exec/some/script/here' on the Raspberry Pi's command line (as user 'pi'), it also gets triggered by the server. So the question is, how do tell the Raspberry Pi's operating system to 'use' the key of the 'pi' user when the 'motion' user tries to ssh into the more powerful server, in that on_motion_detected event?
Asked by Uzumaki Naruto (157 rep)
May 18, 2014, 12:41 AM
Last activity: Apr 28, 2020, 01:17 PM