Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: ambaum01 on December 27, 2012, 03:15:39 PM
-
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.
-
Have you restored all keys in ~/.ssh at boot?
-
Hi tinypoodle
Since bootlocal.sh runs as root, wouldn't that be /root/.ssh ?
-
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.
-
Hi tinypoodle
So maybe something like
su tc -c scp /home/dir/file.txt username@SERVER:/company/dir
-
su tc -c 'scp /home/dir/file.txt username@SERVER:/company/dir'
or
su -c 'scp /home/dir/file.txt username@SERVER:/company/dir' tc
-
su tc -c 'scp /home/dir/file.txt username@SERVER:/company/dir'
This works wonderfully! Although, I do have to put sleep 1 before it. Thank you very much!
-
Glad I could help, but it was rather Rich pointing out the core of your issue ;)
You omitted to mention which scp you are using, assuming openssh, in case of dropbear an additional parameter of "-i /path/to/identityfile" may be required.
-
Just to follow up, I did not have to include -i /path/file. I assume it's because I did not rename the public and private key file names.
Thanks to all who helped out.
-Aaron
-
Just to follow up, I did not have to include -i /path/file.
It would be more useful if you could clearly state which ssh version you are using...
-
I'm using OpenSSH_6.0p1, OpenSSL 1.0.0i 19 Apr 2012
-
So that explains why the "-i /path/to/key" may be omitted; OpenSSH searches in a default path, while with dropbear the path option appears to be a mandatory statement (SSL is without relevance).