Service:shell_command failure executing ssh

As part of a distributed control system I want to mirror in HA the presence or absence of a file on a remote, insecure, server.

My chosen approach is to regularly check the remote system for the file in question and update the local system appropriately. At the moment I have:

  1. A shell script ‘/config/’ which manages the mirror:
ssh -q user@remote [[ -f remote_file ]] && touch /config/local_file || rm -f /config/local_file

If I execute /config/ from the HA terminal then it accurately creates / deletes /config/local_file dependent upon the presence or absence of remote_file.

  1. A shell command alias (myscript) for /config/ set up in configuration.yaml:
  myscript: /config/
  1. An automation to execute /config/ once a minute.
- id: 'schedule_1m'
  alias: 'Schedule: every minute'
  description: ''
    - platform: time_pattern
      minutes: '/1'
  condition: []
    - service: shell_command.myscript
      data: {}
  mode: single

The automation executes every minute, but the ssh test on the remote server always fails. There are no errors: with the flag file present on the remote server I can execute and see the local flag file appear on my system, but it will shortly be removed as the automation executes

My suspicion is that the environment in which ssh is being executed within the automation is limiting something - perhaps the ssh key for the remote server is not accessible from within the shell_command context?

I wonder if anyone has any thoughts?