Recently, using BusyBox to customize a very simple root filesystem for arm-based boards, because BusyBox only supports telnet and does not support SSH, this article describes in detail how to cross-compile dropbear and port it to a target board to enable Dropbear.
Target Environment:
Cpu:arm
Kernel version: 4. X
Tool Download:
zlib-1.2.8
dropbear-2016.74.tar.bz2
Step one: Compiling zlib-1.2.8
Download zlib-1.2.8.tar.gz, the author put it in the/home/liangwode/test directory.
mkdir -pv build/zlib build/dropbear
tar xvzf zlib-1.2.8.tar.gz
cd zlib-1.2.8
Enter the Zlib directory after decompression, configure the Zlib
./configure--prefix=/home/liangwode/test/build/zlib
Modify the generated makefile
CC = arm-linux-gnueabi-gcc (modified according to the cross toolchain used)
AR = arm-linux-gnueabi-ar
RANLIB = arm-linux-gnueabi-ranlib
LDCONFIG = arm-linux-gnueabi-ldconfig
LDSHARED = $ (CC) -shared -Wl, -soname, libz.so.1,-version-script, zlib.map
CPP = $ (CC) -E
Compiling and installing
Make && make install
The relevant files for the Zlib library are generated under/home/liangwode/test/build/zlib
Step two: Compile Dropbear
Back to/home/liangwode/test, unzip Dropbear
bzip2 -d dropbear-2016.74.tar.bz2
tar xvf dropbear-2016.74.tar
Go to dropbear directory, configure Dropbear
cd dropbear-2016.74
./configure --prefix=/home/liangwode/test/build/dropbear --with-zlib=/home/liangwode/test/build/zlib CC=arm-linux-gnueabi-gcc --host=arm
Compiling and installing
make
make scp
make install
Copy SCP to installation directory
CP Scp/home/liangwode/test/build/dropbear/bin
Step three: porting to the target board
First mount the target board root file system, the author uses TF card, divided two areas, one is boot, one is Sysroot
Mount/dev/sdc2/mnt/sysroot
Copy Library and executable file to target system
cp -frP /home/liangwode/test/build/zlib/lib/* /mnt/sysroot/usr/lib
cp -fP /home/liangwode/test/build/dropbear/bin/* /mnt/sysroot/usr/sbin
cp -fP /home/liangwode/test/build/dropbear/sbin/* /mnt/sysroot/usr/sbin
sync
Unmount the SD card and start the target board
Umount/mnt/sysroot
Create a Dropbear configuration directory and generate a key
mkdir /etc/dropbear
cd /etc/dropbear
dropbearkey -t rsa -f dropbear_rsa_host_key
dropbearkey -t dss -f dropbear_dss_host_key
Add system Startup Service
vi /etc/init.d/rcS
add /usr/sbin/dropbear
Reboot the target board and log in with your PC via SSH (with your existing account password).
Dropbear enable SSH for arm embedded Linux cross-compilation based on BusyBox root file system