dropbear scp call in a startup script (no tty)

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
redhat27
DD-WRT Novice


Joined: 20 Jan 2010
Posts: 41

PostPosted: Wed Apr 27, 2011 19:17    Post subject: dropbear scp call in a startup script (no tty) Reply with quote
Hi,

Has anybody been able to use the scp in a std/mega firmware build to fetch some files at router startup?

I have a 4MB flash router with std (nohotspot/nostor) with no space available if I enable jffs. I have a startup script that will write out a rsa key and add an entry to the known_host for another machine (192.168.1.2) that I want to pull files from.

My startup has an entry like
Code:
scp -P 443 -i /tmp/store/RSAKey.dbclient root@192.168.1.2:/jffs/store/* /tmp/store


(sshd on 192.168.1.2 is listening on port 443)

However, scp refuses to work from the startup script script (logs an exit code of 1). If I just telnet/ssh in and run the /tmp/.rc_startup, then scp works! (no user input)

I've researched dropbear scp, but am unable to find something that would help me

I've tried scp with -t to emulate a terminal, tried ssh to the other machine (192.168.1.2) and run scp from there to the router... Nothing works Sad

Help?
Sponsor
redhat27
DD-WRT Novice


Joined: 20 Jan 2010
Posts: 41

PostPosted: Thu Apr 28, 2011 23:56    Post subject: Reply with quote
Hate to bump this, but I'm pulling my hair out trying to get the scp to work at startup Sad

Anyone?
SteveDemy
DD-WRT Novice


Joined: 30 Jul 2008
Posts: 9

PostPosted: Thu May 10, 2012 8:55    Post subject: Reply with quote
I have the same situation. My rc_startup script runs perfectly when activated manually by ssh. It also runs almost perfectly when started by, or contained in rc_startup. That means that when I put a bunch of echo traps in the script, I can see what it's doing and what it's not. Everything works except the scp calls. There is no apparent reason for it. I've tried:

/usr/bin/scp instead of scp in the script,
PATH=... to match the PATH that I have when logged on as ssh

No joy. It sure would be nice to get this working. I could use WGET or something, but standardizing on SCP across the script family has its advantages...

Kernel information:
Linux , 2.6.34.10 #225 Mon Oct 31 00:22:26 CET 2011 mips GNU/Linux
DD-WRT v24-sp2 std (c) 2011 NewMedia-NET GmbH
Release: 10/31/11 (SVN revision: 17798)
Buffalo WZR-HP-G300NH2
redhat27
DD-WRT Novice


Joined: 20 Jan 2010
Posts: 41

PostPosted: Thu May 10, 2012 14:33    Post subject: Reply with quote
Wow! Over an year has passed since my posts Laughing

I got past this. cron is your friend Wink Schedule a one time cron job at startup to do the scp.

Hope this helps.
SteveDemy
DD-WRT Novice


Joined: 30 Jul 2008
Posts: 9

PostPosted: Fri May 11, 2012 0:20    Post subject: Reply with quote
Fantastic tip. I guess the issue with rc_startup is that the script is not being run by the root user. I can't find a way to do that.

So cron ... never tried that. Partial success (for testing) using:

*/5 * * * * root /jffs/usr/bin/start_wanipreport.sh &

It runs every 5 minutes as advertised. But how to get only one run at startup? I've tried these with no joy so far:

@reboot root /jffs/usr/bin/start_wanipreport.sh &
root /jffs/usr/bin/start_wanipreport.sh &
? ? ? ? * root /jffs/usr/bin/start_wanipreport.sh &

Do you know the DD-WRT syntax for running once at reboot?

Thanks!
SteveDemy
DD-WRT Novice


Joined: 30 Jul 2008
Posts: 9

PostPosted: Fri May 11, 2012 8:00    Post subject: Reply with quote
I got by with a workaround here:

1) rc_startup loads a crontab file which tries to load my script every minute
2) the cron process starts my script using root so all works including scp
3) my script stops cron, removes the crontab file, then restarts cron so that it can do its system stuff but doesn't try to re-call my script every minute

Kludgy, but it works as if the rc_startup process called my script, except that scp works this way.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum