I have configured DropBear SSH in a Linux (Ubuntu 22.04) machine. The configuration I'm using is the following:
$ cat /etc/dropbear-initramfs/config
#
# Configuration options for the dropbear-initramfs boot scripts.
# You must run update-initramfs(8) to effect changes to this file (like
# for other files under the '/etc/dropbear-initramfs' directory).
#
# Command line options to pass to dropbear(8)
#
# -I 0: disables idle timeouts for innactivity
# -s: disable passwords
DROPBEAR_OPTIONS="-p 2222 -I 0 -s"
#
# On local (non-NFS) mounts, interfaces matching this pattern are
# brought down before exiting the ramdisk to avoid dirty network
# configuration in the normal kernel.
# The special value 'none' keeps all interfaces up and preserves routing
# tables and addresses.
#
#IFDOWN=*
And I have tested it powering down (manually) the machine; the server starts immediately after startup and I'm able to connect to it. However, if I run sudo reboot
from the machine itself, the server does not start after rebooting and I can't connect to the SSH server of DropBear (logs in the machine show that DropBear is running but the machine is not reachable in 2222).
The only sequence that seems to work (almost every time) is if I restart the machine doing:
$ sudo -i
# echo 1 > /proc/sys/kernel/sysrq
# echo b > /proc/sysrq-trigger
I'm not entirely sure why but I guess the signals sent to reboot the machine are different between the two aforementioned methods. Can this be the issue? What's the best way to reboot a machine and have DropBear running after rebooting?