SCP a file from Hass.io to another server

So I’m trying to transfer a file (a TTS MP3) from Hass to another server (Asterisk) on my network via SCP.

I can do this no problem with a bash script if I call it from the command line, but if I try to set it up as an automation it silently fails.

I can use SSH between servers using automations thanks to being able to say “no” to stricthostchecking - but not sure how to do this for SCP?

Any tips?

Thanks!

Check the username?

nah, it’s not that

So first I would say when I started making complex command line sensors and shell commands, the portainer add-on quickly became my best friend. Do you have that set up? If so go into and go to Containers -> homeassistant -> console. Click connect and in the terminal execute the scp command exactly as you have it written in sensor/command.

The reason this is important is running it from the portainer add-on like this is running in exactly the same context that HA will run it under. If you set up either of the ssh add-ons to HA and then ssh in to test out your command that’s not actually the same. Each add-on runs in its own container with its own environment and dependencies including the ssh add-ons so when you ssh in using the add-on to run your command you’re comparing apples to oranges. Just because it works there doesn’t mean it will work when HA runs it from the sensor or shell command. Whereas if your command works from the console in the homeassistant container in portainer then you know it works at runtime.

Also can you share the command you are using? And where you are trying to put the command? Specifically if you are trying to put it in a shell_command because that adds a few extra restrictions on the runtime context for the commands such as blocking piping.