1#!/bin/echo Try "scripts/mkroot.sh dropbear" 2 3# Example overlay file, adding dropbear (which requires zlib) 4 5echo === download source 6 7download a4d316c404ff54ca545ea71a27af7dbc29817088 \ 8 http://downloads.sf.net/libpng/zlib-1.2.8.tar.gz 9 10download 820ec2b8c869edbcf5ad1138777fc0f54349505c \ 11 https://matt.ucc.asn.au/dropbear/releases/dropbear-2019.78.tar.bz2 12 13echo === Native build static zlib 14 15setupfor zlib 16# They keep checking in broken generated files. 17rm -f Makefile zconf.h && 18CC=${CROSS_COMPILE}cc LD=${CROSS_COMPILE}ld AS=${CROSS_COMPILE}as ./configure && 19make -j $(nproc) || exit 1 20 21# do _not_ cleanup zlib, we need the files we just built for dropbear 22cd .. 23 24echo === $HOST Native build static dropbear 25 26setupfor dropbear 27# Repeat after me: "autoconf is useless" 28echo 'echo "$@"' > config.sub && 29ZLIB="$(echo ../zlib*)" && 30CFLAGS="-I $ZLIB -O2" LDFLAGS="-L $ZLIB" ./configure --enable-static \ 31 --disable-wtmp --host=${CROSS_BASE%-} && 32sed -i 's@/usr/bin/dbclient@ssh@' options.h && 33sed -i 's@\(#define NON_INETD_MODE\) 1@\1 0@' default_options.h && 34make -j $(nproc) PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" MULTI=1 SCPPROGRESS=1 && 35${CROSS_COMPILE}strip dropbearmulti && 36mkdir -p "$ROOT"/{bin,etc/{rc,dropbear},var/log} && 37touch "$ROOT"/var/log/lastlog && 38cp dropbearmulti "$ROOT"/bin || exit 1 39for i in "$ROOT"/bin/{ssh,dropbear,scp,dropbearkey} 40do 41 ln -s dropbearmulti $i || exit 1 42done 43cleanup 44 45rm -rf zlib-* 46 47# user root password root, user guest no password 48echo -e 'root:$1$939UTPzb$/PfVYAsF2Hqi/AQ3UBjbK/:::::::\nguest::::::::' > "$ROOT"/etc/shadow && 49chmod 600 "$ROOT"/etc/shadow && 50 51echo 'netcat -p 22 -L dropbear -iRB &' > "$ROOT"/etc/rc/dropbear && 52 53# file to run on host to ssh into guest 54echo 'ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" ${1:+$1@}127.0.0.1 -p 2222' > "$OUTPUT"/ssh2dropbear.sh && 55chmod +x "$OUTPUT"/ssh2dropbear.sh 56 57# Forward 127.0.0.1:2222 into qemu instance 58QEMU_MORE="-nic user,hostfwd=tcp:127.0.0.1:2222-:22" 59