Cant seem to run ssh script as a service

Hi all. im trying to execute a shell command to make my MBP go to sleep via a script in HAS. i have successfully setup ssh and created a script in bash to sleep the mac and it works really well. (also made the script executable)

now im trying to follow the HAS guide on shell commands (Shell Command - Home Assistant) yet for the life of me cant get it to work

i have setup the command in config.yaml

  mac_sleep: bash /root/config/scripts/

and then i try to call that service yet nothing happens, logs say it ran. any clue?

1 Like

Maybe permissions at the host?
Take a look at the logs on the MBP.

I assume you set up a ssh key? Follow this guide to get it to work from ha.

thx @Mikefila

yeah ssh is setup and woks well.

I can run the command perfectly from command line on the HAS machine, ie

ssh -t macbook 'pmset sleepnow'

but the same script when I try to launch it from within a HAS script fails with an error in the logs

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/ 
Integration: Shell Command (documentation, issues) 
First occurred: 20:17:49 (4 occurrences) 
Last logged: 20:43:21

Error running command: `bash /root/config/scripts/`, return code: 127
NoneType: None

im kinda lost on why it dosent work

thx again all really appreciate the help!


Please read that guide to properly setup the keys. You have set up keys for the terminal container only. Ha needs it’s own key that is why it is failing. The guide explains how to setup a key for ha.

thx all.

turns out when using home assistant OS at least, (didnt check other options) you also need to make sure the .ssh folder (with the private keys, config etc) is moved to \config folder

did that and if Finally worked :slight_smile:

hope other people can find the solution helpful

thx again!!