Input_button automation calling shell_command over SSH does not trigger

Hi all,

I’m trying to setup a one-tap “Plex Server Off” button in Home Assistant for an Ubuntu Plex Server. Wake on LAN works perfectly via the normal WOL integrations section in HA;, the shutdown side is what I’m stuck on. I’m trying to setup a HA dashboard button that, when pressed, SSHes into the Ubuntu server and runs shutdown -h now, so the machine doesn’t get left running for days.

As regards the environment, I’m running Home Assistant OS (Green) - current 2025.x release., Terminal & SSH add-on is installed and working. And Advanced Mode is enabled. The target machine is an old Dell Optiplex running Ubuntu Server and an XFCE desktop. I can control it with a bluetooth keyboard/trackpad and a 5 inch HDMI monitor in a pinch, but I want my wife to be able to turn it on and off via the ipad in the kitchen (HA app is installed on the ipad). SSH access is working on the ubuntu server and sudo /sbin/shutdown -h now works normally when run manually on the ubuntu/plex server.

  1. Passwordless SSH from Home Assistant is confirmed working.
    ssh -i /config/ssh/id_ed25519 [email protected] echo ok
    returns ok
    On the Ubuntu server, sudoers contains:
    mccabesplexserver ALL=NOPASSWD: /sbin/shutdown

  2. The shell_command is defined and visible:
    In /config/configuration.yaml:

shell_command:
plex_server_shutdown: >
ssh -i /config/ssh/id_ed25519
[email protected]
sudo /sbin/shutdown -h now

Home Assistant was restarted, and
shell_command.plex_server_shutdown appeared in Developer Tools → Actions.

  1. I created an input helper button called “Plex Server off” with an entity ID of input_button.plex_server_off

  2. I created an automation via UI, it’s a state trigger input_button.plex_server_off that performs the action: shell_command.plex_server_shutdown

  3. I created a button card using shell_command.plex_server_shutdown
    It appears and is pressable

When I press the dashboard button (pictured), nothing happens - the plex server doesn’t shut down. Pressing it multiple times has no effect. The Wake-on-LAN command works perfectly fine from the same dashboard so its not a connectivity issue. Appreciate any guidance, thank you in advance.

Does the shell command work when you run it from Developer tools → Actions?

if not, then share this again but format it correctly for the forum:

Sorry about the formatting. I ran shell_command.plex_server_shutdown directly from Developer Tools → Actions.

Result:

stdout: ""
stderr: Host key verification failed.
returncode: 255

Now you know why it does not work. You need to include SSH authentication. See: SSH'ing from a command line sensor or shell command

Thanks, though I’m still very confused… I thought SSH authentication was already set up, because I can SSH into the Ubunutu/Plex server from another Linux Mint laptop.

Can you tell me what I need to change so Home Assistant itself is allowed to SSH into the Plex server?

Home Assistant is not that other laptop. That laptop has pre-shared keys set up. Home Assistant needs pre-shared keys set up too.

Follow the instructions in the link I posted.

That fixed it, thanks.

Adding -o StrictHostKeyChecking=no to the shell_command resolved the issue immediately.

After restarting Home Assistant, the dashboard button now shuts the Plex server down correctly.

Appreciate the help.

1 Like