Trying to remote power down remote linux machine, not working

I am running HA 2025.12.5 on bare metal… My goal is to shutdown my backup unraid system via an automation when the power load drops to a set point for 4 minutes. This all worked when running the Unraid-API-RE container on Unraid prior to upgrading server to 7.2.x. The container was designed for 6.x.x and just became broken.

I had a switch defined in HA that would bring up the machine with WOL (still works) and then would take it down with an Unraid-API-RE service call (quit working). So, I decided to do the shutdown via a command line in the switch config. The command line works perfectly via the HA cli, but will not work when the switch is clicked or an automation tries to use it.

I have added a command_lines.yaml to my config directory and done the require include in the configuration.yaml file. The command is being found as indicated by the error logs.

Error message:

Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:129
integration: Shell Command (documentation, issues)
First occurred: 12:47:41 PM (1 occurrence)
Last logged: 12:47:41 PM
Error running command: `ssh -v -i /config/.ssh/id_rsa_unraid [email protected] 'shutdown -h now'`, return code: 255

NoneType: None

This exact command from the cli in HA works perfectly and returns exit code 0 as it should:

ssh -v -i /config/.ssh/id_rsa_unraid [email protected] 'shutdown -h now'

shell_commands.yaml entry"

turn_off_backup_server: "ssh -v -i /config/.ssh/id_rsa_unraid [email protected] 'shutdown -h now'"

I do have turn_off_backup_server appearing in developer tools as shell_command.turn_off_backup_server

switch.yaml entry for device:

  - platform: wake_on_lan
    mac: "BC:5F:F4:xx.xx.xx"
    name: "Backup"
    host: 192.168.1.xxx
    broadcast_address: 192.168.1.255
    turn_off:
      service: shell_command.turn_off_backup_server

What am I doing wrong, gonna wear my HA machine out rebooting for each test change a this point. I have tried many iterations of the shutdown command and added -v so that when tested from the cli I could see the entire process and it all looks great. I have tried it with and without sudo and the ’ ’ around the command and no difference. The sudo should not be required by this user.

I seem to get this error on unraid.

Jan 16 13:12:38 Backup sshd-session[34134]: Connection closed by 192.168.1.6 port 53348 [preauth]
Jan 16 13:12:38 Backup sshd[1781]: srclimit_penalise: ipv4: new 192.168.1.6/32 deferred penalty of 1 seconds for penalty: connections without attempting authentication

Thanks Matt

Ok, I figured out what I did wrong… I created the keys in the normal cli window and was testing from the normal cli window, this window drops into the container for Advanced SSH & Web Terminal.

I had to change to the HA container and perform the first password required login from this container, once completed it works as it should.

Command to change containters:

docker exec -it homeassistant bash

Remeber that if you want to get back to the base cli console you will need to exit this docker container!