Shell_command failing to run - return code 127

I am attempting start and stop windows services via HA using net rpc. I have the commands successfully starting and stopping services on a windows pc on the network via the web terminal add-on but can’t get them to run in a shell_command in the configuration.yaml.

Abbreviated error message down to the basics from the logs:

Error running command: `net rpc`, return code: 127
NoneType: None

I understand this means that the command net isn’t installed and so the command couldn’t be found. I installed the required samba toolkit in terminal to get it working but from my limited understanding, I am lead to believe the command is running in a different container to the terminal add-on.

To get HA running, I simply followed the guide on home-assistant.io and installed it directly on an SD card, I didn’t specifically set up docker instances. My knowledge on docker containers and Linux is pretty limited, I am very much a windows dev.

Shell command which I am testing via the developer tools:

shell_command:
  test_net: "net rpc"

Do I need to go down the complicated route of setting up ssh’ing to the other container or is there a simpler way to get this shell_command to work?

Actual commands I want to use (that work, with different creds, via the terminal add-on):

shell_command:
  start_service: "net rpc service start CustomService -I 192.168.1.64 -U user%password1"
  stop_service: "net rpc service stop CustomService -I 192.168.1.64 -U user%password1"

There is no getting around setting up keys for shell commands, unless you leave everything wide open and unsecured. This guide should make it pretty straight forward.

net is a pure windows command. You don’t have a choice but to ssh to the windows machine to execute it.

Thanks for this. I will take another look at that guide and work my way through it.

From that article, I have generated the keys and now have to ssh-copy-id across to the other container. What user I should be using with the IP address?

The machine that you are logging into, your windows admin user.