Command doesnt work with rc.d

i have 2 scripts
/root/start.sh

#!/bin/ash
/bin/ash /root/scp.sh &

/root/scp.sh

#!/bin/ash
sleep 1
export SSHPASS=1
/usr/bin/sshpass -e scp /tmp/rmm_nr_own_report root@192.168.222.1:/tmp/neighbors/rmm_own_report$HOSTNAME

if i start from console /root/start.sh all works fine it sends file to remote host
but if i add to init.d and rc.d i see that start.sh started then scp.sh started but it stacking on
sshpass -e scp /tmp/rmm_nr_own_report
i dont even know how to check because when i start start.sh from console it works

and the command should be executed only after actually the network works, if not it will fail...

can you try creating some ssh keys and using the preshared keys method?

no i cant :frowning_face:
the size of it 1.34Mb and i use 8 Mb flash routers
but it is really triki why doesnt it works when i started it via script which started by system in background
i know there is way to try with preshared keys but why sshpass dont work when it started by system

reverse hosts ?

instead of A to B

B to A?

they are both the same OpenWrt routers same firware 22.05.03

See Why I can't run ssh tunnel on startup?

1 Like

do you have any NAS or another pc/server always on?

A -> C

B -> C

follow the advice of:

in this topic
[Why I can't run ssh tunnel on startup?]
he typed

Thanks guys for your help. I came to solution! :blush: First, I executed from rc.local "yes | ssh...." and looked what changed. Ssh created /.ssh/known_hosts on the device (yeah, indeed in the / folder). For

but what exactly he did

yes answers "y" to another program (ssh) prompt "Do you want to continue connecting? (y/n) "

but i use scp and sshpass and looks like there is no yes option

Check what's going on as suggested here Why I can't run ssh tunnel on startup? - #2 by AndrewZ

when i run the comnad in console with -vvvv i see


root@AP2:~# /usr/bin/sshpass -vvvv -p '1'  scp -P 22 /tmp/rmm_nr_own_report root@192.168.222.1:/tmp/neighbors/rmm_own_report$HOSTNAME  /usr/bin/sshpass -vvvv -p '1'  scp -P 22 /tmp/rmm_nr_own_report root
@192.168.222.1:/tmp/neighbors/rmm_own_report$HOSTNAME >> /tmp/mylogifile.log>> /tmp/mylogifile.log
SSHPASS: searching for password prompt using match "assword"
SSHPASS: read: root@192.168.222.1's password:
SSHPASS: detected prompt. Sending password.
SSHPASS: read:

but how i will see the output with -vvvv when it is started by rc.d ?
i tried like this but mylogifile is empty

 /usr/bin/sshpass -vvvv -p '1'  scp -P 22 /tmp/rmm_nr_own_report root@192.168.222.1:/tmp/neighbors/rmm_own_report$HOSTNAME >> /tmp/mylogifile.log

Read the next message in that topic.
You need to replace >> /tmp/mylogifile with 2>/tmp/mylogfile

yeah well it asks for confirmation


Host '192.168.222.1' is not in the trusted hosts file.
(ssh-ed25519 fingerprint SHA256:FpB893tBVdJRX63XR4vBS4yOLqAEdgN31Rhs2zm25wM)
Do you want to continue connecting? (y/n) 

but where do i put that confirmation if i use scp and sshpass and sshpass does not have yes option

Connect once manually so it gets added in the trusted hosts file.

1 Like

why not extract passwords from:

/etc/dropbear

dropbearkey -h
Usage: dropbearkey -t <type> -f <filename> [-s bits]
-t type Type of key to generate. One of:
                rsa
                ed25519
-f filename    Use filename for the secret key.
               ~/.ssh/id_dropbear is recommended for client keys.
-s bits Key size in bits, should be a multiple of 8 (optional)
           Ed25519 has a fixed size of 256 bits
-y              Just print the publickey and fingerprint for the
                private key in <filename>.
dropbearkey -f /etc/dropbear/dropbear_rsa_host_key -y

and add them to allowed hosts?

no it wont as i learned today when executing from rc.d it has it is own trustet list

Copy /root/.ssh/known_hosts to /.ssh/known_hosts and see if it helps.

i dont have .ssh in my root folder

root@AP2:~# ls /root/
Candidates        KIKALOG           dummies           kicker.sh         mykikaconsole.sh  neigborsguest     neighbors         setupmykika061
root@AP2:~#