Tiny Image: Dropbear with Busybox
Docker Image
1 min readMay 21, 2023
Initialize Ubuntu
Ubuntu 18.04.
Use cloud-init:
packages:
- git
- build-essential
- curl
- wget
- nano
- vim
- ltrace
- strace
- ca-certificates
- socat
Install requirements
apt install mpc binutils libncurses-dev linux-headers-generic libssl-dev musl musl-tools musl-dev zlib1g-dev libtomcrypt-dev libc6-dev
Reboot.
Clone SRC
Here, we are building rootfs, not bootloader, nor kernel image.
- https://busybox.net/downloads/busybox-1.35.0.tar.bz2
- https://github.com/mkj/dropbear/archive/refs/tags/DROPBEAR_2020.81.tar.gz
Build with non-root user.
Dropbear
$ autoconf; autoheader
$ ./configure --enable-static --with-zlib=/usr/lib/x86_64-linux-gnu
$ cp ./default_options.h localoptions.h # if not exist
$ vim ./localoptions.h
$ CFLAGS="-I/usr/include -ffunction-sections -fdata-sections" LDFLAGS="/usr/lib/x86_64-linux-gnu,-Wl,--gc-sections" make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 STATIC=1 strip
$ cp dropbearmulti ../
Link script:
mkdir -p /usr/bin
cd /usr/bin
dbmtoollets=(scp dropbearkey dropbearconvert dropbear ssh dbclient)
for i in "${dbmtoollets[@]}"
do
ln -s dropbearmulti $i
done
Busybox
Download source code.
Run:
$ make menuconfig
$ LDFLAGS="--static" make -j 2
Link Script:
cd /usr/bin
busybox install -s /usr/bin
Docker
You should be aware that dropbear
SSH server still relies on /etc/passwd, /etc/shadow, /etc/group
, so you still need a distro as backend.