mtchang / rt-n56u

Automatically exported from code.google.com/p/rt-n56u
0 stars 0 forks source link

SSH keys recreated after every reboot #943

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.compile the current trunk 
2.install on the router
3.connect with ssh

What is the expected output? What do you see instead?
Connect of the ssh will use the old keys.
A new ssh key is generated after each reboot of the server

What version of the product are you using? On what operating system?
Current trunk

Please describe the problem as detailed as it's possible.

On every reboot new ssh keys are generated, forcing me to update my known_hosts 
everytime I install a new firmware.

Problem is with the sshd.sh file. For some reason the or statement represented 
with a || is not used correctly. Executing it on the commandline (through ssh), 
gives the following output:

/home/root # if [ ! -f "/etc/storage/dropbear/dss_host_key" || ! -f 
"/etc/storage/
dropbear/rsa_host_key" ] ; then echo "not found" ; fi
sh: missing ]
-sh: -f: not found
not found

Replacing the || with '-o' in the sshd.sh file should fix the error, at least 
it does on the console.

The correct line should read like (line 31-33):
        if [ ! -f "$rsa_key" -o ! -f "$dss_key" ] ; then
                func_createkeys
        fi

Original issue reported on code.google.com by jord.sw...@jordswart.org on 19 Aug 2013 at 6:51

GoogleCodeExporter commented 9 years ago
The statement is correct there:
[ ! -f "$rsa_key" ] || [ ! -f "$dss_key" ] is the same as [ ! -f "$rsa_key" -o 
! -f "$dss_key" ]
Check your key files were moved from /etc/storage to /etc/storage/dropbear

Original comment by d...@soulblader.com on 19 Aug 2013 at 8:39

GoogleCodeExporter commented 9 years ago
I know both statements are correct and both SHOULD be working. However as you 
can see from my original request: the one using the || creates and error on the 
command line. The one using -o does not. I also can confirm that the one using 
|| recreates the ssh keys on every boot.

I guess this is caused by a change in busybox, but I am not sure here.

Original comment by jord.sw...@gmail.com on 19 Aug 2013 at 9:52

GoogleCodeExporter commented 9 years ago
No, [ statement_0 || statement_n ] - is incorrect!
[ statement_0 ] || [ statement_n ] or [ statement_0 -o statement_n ] is the 
correct form!
You tried construction not from sshd.sh, you forgot internal brackets...

Anyway, it seems the problem was that your keys were moved to wrong path. I 
think it is fixed now, see: 
https://code.google.com/p/rt-n56u/source/detail?r=00fc7e9d15269829ffe100549d99b8
5ba97064b7

Original comment by d...@soulblader.com on 19 Aug 2013 at 10:07

GoogleCodeExporter commented 9 years ago
I am sure that my sshd.sh had the incorrect line.

But if it is fixed, I am happy :-)

Original comment by jord.sw...@gmail.com on 20 Aug 2013 at 7:27

GoogleCodeExporter commented 9 years ago

Original comment by andy.pad...@gmail.com on 1 Sep 2013 at 10:38