This is an old revision of the document!
This page will show a method how to install and get ssh access using dropbear.
The steps below require the following dependencies. Install them first:
sudo apt-get install git build-essential libncurses-dev
The dropbear binary can be easily built using buildroot. For this, we clone the buildroot-at91 repository because the AT91 architecture is close to the Allwinner V3s ARM Cortex A7 CPU. After git clone, cd into the repository.
git clone https://github.com/linux4sam/buildroot-at91.git cd buildroot-at91
Since we do not have the same build environment as flashforge had, we will create a static build of dropbear. This requires to modify the dropbear package file in buildroot:
sed -i "s/disable-static/enable-static/g" package/dropbear/dropbear.mk
Then we need to configure buildroot for the right processor architecture and target software. Either download the configuration to build dropbear or configure manually, as shown further below:
mv .config .config_ORIG wget -O .config https://www.auditeon.com/xyz/flashforge_dropbear_br2023.10.config
make menuconfig
Then set the following options accordingly:
Target options: Target Architecture (Arm (little endian)) Target Architecture Variant (cortex-A7) Target ABI (EABI) Floating point strategy (VFPv4) ARM instruction set (ARM) Target Binary Format (ELF) Toolchain: C library (glibc) Kernel Headers (Linux 6.1.x kernel headers) *** Glibc Options *** -> Enable compatibility shims to run on older kernels (enable this option) Build options: strip target binaries (Enable this option) libraries (both static and shared) <-- this will set BR2_SHARED_STATIC_LIBS=y for dropbear, together with patching packages/dropbear/dropbear.mk Target packages: Networking applications ---> * dropbear (enable this option) * client programs (enable this option) * optimize for size (enable this option)
Go back to the main screen (click twice on exit) and click on Save
make
This step may take about 20 minutes (core i7-1370P x 20). When done, verify if dropbear is correctly built:
file output/target/usr/sbin/dropbear
We should see the following:
dropbear: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, stripped
To get SSH on the printer, we will create a special USB stick. Insert an empty FAT formatted USB stick in your PC and copy dropbear to the main directory:
cp output/target/usr/sbin/dropbear /media/$USER/USBSTOR/
Replace USBSTOR with the name of the USB stick.
Write following script to the main directory of the USB stick with the name flashforge_init.sh
#!/bin/sh set -x WORK_DIR=`dirname $0` MACHINE=Creator3Pro PID=0014 #Test the machine's architecture and quit immediately if there's an error. CHECK_ARCH=`uname -m` if [ "${CHECK_ARCH}" != "armv7l" ];then echo "Machine architecture error." echo ${CHECK_ARCH} exit 1 fi cat $WORK_DIR/start.img > /dev/fb0 #create_key # 1. copy dropbear to /usr/sbin/ cp $WORK_DIR/dropbear /usr/sbin/dropbear chmod 755 /usr/sbin/dropbear # 2. create a symlink dropbearkey and dropbearconvert to dropbear in /usr/sbin ln -s /usr/bin/dropbearkey /usr/sbin/dropbear ln -s /usr/bin/dropbearconvert /usr/sbin/dropbear # 3. create a symlink scp to dropbear in /usr/bin ln -s /usr/sbin/dropbear /usr/bin/scp # 4. create rsa key in /etc/dropbear/ (e.g. /etc/dropbear/dropbear_rsa_host_key) mkdir -p /etc/dropbear dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key # 5. Add dropbear as an init.d script cat << 'EOF' > /etc/init.d/S50dropbear #!/bin/sh # # S50dropbear Starts dropbear. # # please note: if not added in rcS like: # ifconfig eth0 hw ether 88:A9:A7:93:CD:EF # the MAC address may change everytime when the board restarts. # Make sure dropbearkey exists [ -f /usr/bin/dropbearkey ] || exit 0 # Make sure dropbear exists [ -f /usr/sbin/dropbear ] || exit 0 SSH_HOST_KEY=/etc/dropbear/dropbear_rsa_host_key umask 077 start() { # check for public key, ssh-rsa type and for fingerprint if /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "Public key portion is" && /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "ssh-rsa" && /usr/bin/dropbearkey -y -f ${SSH_HOST_KEY} | grep -q "Fingerprint"; then printf "Starting sshd: " /usr/sbin/dropbear touch /run/dropbear.pid echo "OK" else # Create any missing keys printf "Creating ssh keys..." mkdir -p /etc/dropbear /usr/bin/dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key start fi } stop() { printf "Stopping dropbear: " killall dropbear rm -f /run/dropbear.pid echo "OK" } restart() { stop start } case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit $? EOF # 6. set file permissions for S50dropbear chmod 755 /etc/init.d/S50dropbear sync cat $WORK_DIR/end.img > /dev/fb0 $WORK_DIR/play exit 0 EOF # 6. set file permissions for S50dropbear chmod 755 /etc/init.d/S50dropbear sync cat $WORK_DIR/end.img > /dev/fb0 $WORK_DIR/play exit 0
Download the following files:
From this link: flashforge_dropbear_files.tar.bz2 and extract them to the USB stick.
Test the ssh connection to the printer with following user: root