It is possible to use SSH from AppDaemon scripts?

I am making a notification for whenever I have updates pending, both for HA stuff and for various integrations.

For one of those, PiHole specifically, I need to SSH into a machine and run a command to update. The only way I know how to do this is by calling Tasker from AppDaemon, then using the JuiceSSH Tasker plugin and JuiceSSH App on to automate the SSH login and running of a code snippet.

While it probably works (I do something similar for other tasks), it is kind of a detour. Is there some way to do this more directly from AppDaemon?

You can try using sshpass: Power on / off NAS by using WOL and SSHPASS

Depending on what type of updates you want to be notified for of what commands you want to execute, you can as an alternative place a small Python script on the machine and make it “call home” through for instance MQTT or through the REST API and update a sensor or any other entity in HA. I have a few scripts on satellite machines that sends various performance data home to HA that way.

The script can also listen for commands from HA or appdaemon through MQTT and perform any required actions directly on the machine, i.e. acting as a daemon.

What @tjntomas suggested would work. Alternatively, you can use a SSH library for Python like Paramiko. If you go that route, you should run the code that calls the Paramiko code with the run_in_executor API.

Basically, I need to SSH into the RPi (using password protected privatekey), and execute pihole -up (which also requires a password), so nothing too complex.

Thanks, the suggestions looks promising, I’ll give it a go once I’m home from travels.