Page 1 of 1

Problem with "os.execute" in dzventz

Posted: Thursday 18 January 2018 10:00
by cdjseb
Hello.
I'm making a script for rebooting a computer.
When i'm connect to domoticz with SSH, i have a command who is working :

*** ssh user@host -p port sudo reboot *** (user / host / port are different obviously)

but when i include this command in my script, it's not working !

*** os.execute('ssh user@host -p port sudo reboot') ***

Anybody can help me please ?
Many thanks in advance !

Re: Problem with "os.execute" in dzventz

Posted: Thursday 18 January 2018 11:30
by emme
the problem is that in ssh you run the command ad user PI, but domoticz runs as root for which (probably) there is no SSH key exchange between the 2 servers.

try with
os.execute('su pi ssh user@host -p port sudo reboot')

or log as root and connect the remote server the first time to save the key

ciao
M