8devices / openwrt-8devices

OpenWRT for 8devices WiFi modules
GNU General Public License v2.0
86 stars 72 forks source link

Dropbear issue with LIMA build #7

Closed jbman35 closed 3 years ago

jbman35 commented 5 years ago

Hello,

I faced some troubles while using dropbear as a ssh server on my LIMA.

I added dropbear to be started automatically on startup (by putting a link into /etc/rc.d/), no problem it starts properly.

But I observed that the first time dropbear starts this way, the rsa host key are not copied from /tmp/dropear to /etc/dropbear as they should be as shown below:

keygen()
{
    for keytype in rsa; do
        # check for keys
        key=dropbear/dropbear_${keytype}_host_key
        [ -f /tmp/$key -o -s /etc/$key ] || {
            # generate missing keys
            mkdir -p /tmp/dropbear
            [ -x /usr/bin/dropbearkey ] && {
                /usr/bin/dropbearkey -t $keytype -f /tmp/$key 2>&- >&- && exec /etc/rc.common "$initscript" start
            } &
        exit 0
        }
    done

    lock /tmp/.switch2jffs
    mkdir -p /etc/dropbear
    mv /tmp/dropbear/dropbear_* /etc/dropbear/
    lock -u /tmp/.switch2jffs
    chown root /etc/dropbear
    chmod 0700 /etc/dropbear
}

You need to start dropbear manually once, so that the key are properly copied to /etc/dropbear and after that the server starts properly.

I patched the script on my side to have a more sequential approach of the key generation (and it works properly) but I wanted to raised an issue on this script (/etc/init.d/dropbear) that does not seem to work properly.

mantas-p commented 5 years ago

Hello,

Dropbear should start by default, no changes should be needed. Did you wait for JFFS2 build to finish when checking if server started? JFFS2 build for Lima can take few minutes when doing first boot.

0x4C4A commented 5 years ago

Since rebasing my fork (to 936ce5768fd5b2fe405b3bd643395af03d4dbf5b) I've run into this as well. The generated dropbear key files are never copied to the /etc/dropbear directory. If the files are copied by hand, all is fine and dandy. I'm running this on a Carambola2 however.

mantas-p commented 5 years ago

@0x4C4A Try updating to efac53d79f

0x4C4A commented 5 years ago

After rebasing to efac53d I'm happy to report that the issue did not repeat.