I am trying to create a text file and write that text file to a server automatically upon boot. When I execute the following command in terminal after boot, it successfully scps the file:
scp /home/dir/file.txt username@SERVER:/company/dir
When I put that line of code in bootlocal.sh, I got the error:
ssh: Could not resolve hostname SERVER: Name or service not known
lost connection
So I figured it was a timing thing, so I added a long delay:
sleep 60
scp /home/dir/file.txt username@SERVER:/company/dir
But now I get the error:
Host key verification failed.
lost connection
Is this caused by trying to use scp too early in the boot process? Is there a better way to automatically transfer the file as soon as possible after boot? Thanks.