OpenWrt Forum Archive

Topic: Howto autorun ssh on init-script when boot?

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I want box can auto ssh to another linux server when the box boot.

so I add script in init.d.
ssh -i /etc/dropbear/dropbear_rsa_host_key root@172.20.40.1

but it not working.
erro log:
Dec 29 23:40:12 OpenWrt user.info sysinit: Host '172.20.40.1' is not in the trusted hosts file.
Dec 29 23:40:12 OpenWrt user.info sysinit: (fingerprint md5 6e:d1:c6:e7:1c:12:72:e2:af:f6:af:46:21:e8:c3:9a)
Dec 29 23:40:12 OpenWrt user.info sysinit: Do you want to continue connecting? (y/n) ssh: connection to root@172.20.40.1:22 exited: Didn't validate host key

when I run above command at root. it can work fine.

resoved.
use "ssh -y" to Always accept remote host key if unknown.

I'm trying to SCP my way into another machine, and it seems like there is no option equivalent to that with SCP - any ideas?

I have put the pub key of the other machine in my ~/.ssh/know_hosts, but no luck. any other ideas?

thx

lr wrote:

I'm trying to SCP my way into another machine, and it seems like there is no option equivalent to that with SCP - any ideas?

I have put the pub key of the other machine in my ~/.ssh/know_hosts, but no luck. any other ideas?

thx

Thanks for this. and LR, to answer your question simply install...


opkg install openssh-sftp-server


and you will be able to use winscp or your choice of program to access files and transfer.

checking the source code of dropbear, to allow scp in /etc/rc.local or crontab,

you need add "export HOME=/root", so the /root/.ssh/known_host can be found.

The discussion might have continued from here.