Is there any possibility to run scp command in HA instance running on HASS OS?

Hi,

I would like to transfer file defined in shell_command via SCP to the remote server.
I tested such scenario via SSH (where I used official SSH addon to connect to the HASS system) and it worked. But now I’m struggling with Home Assistant instance - it can’t recognize scp command.

This command works flawlessly:

shell_command:
  download_curl: 'curl someHost/test.txt -o /config/files/test.txt'

By this I’m able to download required file. But now I want to transfer it via SCP to the remote server

shell_command:
  transfer_sfile: 'scp -i /config/files/id_rsa /config/files/test.txt user@host:~/'

And I get such error message:

Error running command: scp -i /config/files/id_rsa /config/files/test.txt user@host:~/, return code: 1

I tried to do it even via crontab -e:

# do daily/weekly/monthly maintenance
# min   hour    day     month   weekday command

/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly
* * * * * /config/files/bash.sh
*

But without any luck.

Do you have please any idea how to run SCP via Home Assistant running on HASS? Or any recommendation to addon supplying such scheduled functions to transfer file over SSH?

Thank you.

It looks like CURL supports SCP so you may be able to transfer using the CURL command:

Solved! Thanks!

I was trying different methods how to connect via curl to the synology using SFTP or FTPS but without any luck (and I believe my configuration is 100% correct on synology side) but somehow curl is being refused. So when I used simple FTP connection it works (I suspect certificate or curl protocol support even I included --insecure parameter).

For imagination I’m showing how looks my final configuration:

shell_command:
  download_curl: 'curl someHost/test.txt -o /config/files/test.txt'
  upload_curl: 'curl --upload-file /config/files/test.txt ftp://user:[email protected]/home/'

I’m using this to automate of uploading my latest camera record to different site in case burglar would stolen my local encrypted camera records…

Glad you got it fixed, CURL is a wonderful tool!