Running a remote SSH script from HA

I have a couple of Python scripts on a Raspberry Pi Zero that I use along with a relay HAT to open and close my garage door. I have set up Home Assistant on a Raspberry Pi 4 and am trying to add buttons to my HA dashboard to run these scripts via SSH. To test the setup, I am trying to ssh a simple command of

ssh [email protected] -p xx touch /home/pi/test.txt

which should create a file ‘test.txt’ in the pi user’s home file. I have SSH’d into the HA and tested the command from the command line and it works - it creates a file ‘test.txt’ on the Raspberry Pi at the specified IP address. However, when I click the button on my dashboard it does nothing.
In my configuration.yaml I have,

shell_command:
  test: ssh [email protected] -p xx touch /home/pi/test.txt

(with the correct IP address and port)
And in scripts.yaml I have,

test:
  alias: test
  sequence:
   - service: shell_command.test

The code for the card for the button to run the script is,

show_name: true
show_icon: true
type: button
tap_action:
  action: toggle
name: Test.txt
icon: mdi:test-tube
entity: script.test

I’m fairly new to HA but not to scripting, etc. and any guidance would be most appreciated! I have checked other relevant posts but not found what I need.

As far as I remember its far more complex due to user issues, HASS user a different user to the SSH addon or something, someone will no doubt explain far better than I could.

I use this as it just worked for me, I use it fir shutting down a remote pi.

  1. Whatever way you used to set up your private SSH key, keep in mind, indeed, that the filesystem of the terminal addon is not the same as the one of HA in that regard, so you likely need the -i option with a path to your private key
  2. You likely need -o StrictHostKeyChecking=no, or ssh will not allow connection to an unknown host