-
Where is the constrained environment provided by
shell_command
documented?- It’s very confusing that your commands will work when you connect via the
core-ssh
module and runssh ...
manually, but the exact same command fails when run via HA’sshell_command
definition/service… It’s all the confusion of your regular environment vs a cron job, but with less documentation and more latency…
- It’s very confusing that your commands will work when you connect via the
-
How can you get
shell_commands
to use an SSH wrapper script? I tried to create/config/ssh_wrapper
with all my repetative SSH options, but again, it works from thecore-ssh
command line, and fails via Home Assistant’sshell_command
→call service
-
How can you write a multi-line
shell_command
… YAML supports the>-
syntax that should strip all of the intervening\n
newlines and the trailing\n
but that doesn’t work and even adding\
or\\
or\\\
it still won’t work… -
How can you get
shell_command
drivenssh
to read~/.ssh/config
?
Any of these would be fine… Just some sane way to reduce the repetition and increase the readability of shell commands…
Most importantly, how can you test the shell_command
via HA without having to do a ha core restart
which can take literally minutes if any of your integrations are slow.
Here’s are some of the ssh
permutations that one user tried…
shell_command:
restart_pi: "ssh -l pi 192.168.1.74 'sudo reboot'"
reboot_test: ssh -l [email protected] 'sudo reboot'
test3: ssh -i /config/ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] sudo reboot
test4: ssh -i /config/ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] "sudo reboot"
test5: "ssh -i /config/ssh/id_rsa -o 'StrictHostKeyChecking=no' [email protected] sudo reboot"
test6: "ssh -i 'StrictHostKeyChecking=no' [email protected] sudo reboot"
test7: "ssh -i 'StrictHostKeyChecking=no' [email protected] 'sudo reboot'"
test8: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'sudo reboot'
My actual SSH commands are even worse, because I have autossh running a master channel in the background so my commands can be run with reduced latency:
shell_command:
lights_off: ssh -i /config/ssh_keys/id_rsa -o 'StrictHostKeyChecking=no' -o ControlMaster=no -o ControlPath=/config/ssh_keys/ha.sock -p 999 '[email protected]' LightsOff.sh
However, if this could be written multi-line, especially when making changes to multiple lines…
shell_command:
lights_off: >-
ssh -i /config/ssh_keys/id_rsa
-o 'StrictHostKeyChecking=no'
-o ControlMaster=no
-o ControlPath=/config/ssh_keys/ha.sock
-p 999 '[email protected]' LightsOff.sh