Tiny Core Base > TCB Q&A Forum

using bootlocal.sh to scp

(1/3) > >>

ambaum01:
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:

--- Quote ---scp /home/dir/file.txt username@SERVER:/company/dir
--- End quote ---

When I put that line of code in bootlocal.sh, I got the error:
 
--- Quote ---ssh: Could not resolve hostname SERVER: Name or service not known
lost connection
--- End quote ---

So I figured it was a timing thing, so I added a long delay:

--- Quote ---sleep 60
scp /home/dir/file.txt username@SERVER:/company/dir
--- End quote ---

But now I get the error:

--- Quote ---Host key verification failed.
lost connection
--- End quote ---

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.

tinypoodle:
Have you restored all keys in ~/.ssh at boot?

Rich:
Hi tinypoodle
Since bootlocal.sh runs as root, wouldn't that be  /root/.ssh ?

tinypoodle:
Good catch!

Might be a possible explanation why the command works when interactively executed as tc, but not in bootlocal.sh

Alternatively perhaps invoking su(1) to run scp as tc could be an approach.

Rich:
Hi tinypoodle
So maybe something like

--- Code: ---su tc -c scp /home/dir/file.txt username@SERVER:/company/dir
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version