分类 默认分类 下的文章

git clone https://github.com/mkj/dropbear.git

cd dropbear

cat > localoptions.h << EOF

#define DROPBEAR_SMALL_CODE 0

#define DROPBEAR_ENABLE_GCM_MODE 1

#define DROPBEAR_SHA1_HMAC 0

#define DROPBEAR_RSA 0

#define DROPBEAR_RSA_SHA1 0

#define DROPBEAR_ECDSA 0

#define DROPBEAR_SK_KEYS 0

#define DROPBEAR_DH_GROUP14_SHA1 0
#define DROPBEAR_DH_GROUP14_SHA256 0

#define DROPBEAR_ECDH 0

EOF


 ./configure --prefix=/u01/dropbear/ --enable-static  --disable-zlib --disable-openpty

 make -j2 PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"

 make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install

x86机器的linux下面运行下面命令

sudo apt install debootstrap -y
sudo apt-get install qemu-user-static -y
mkdir debian8-rootfs
cd debian8-rootfs

wget  https://ftp-master.debian.org/keys/release-8.asc -qO- | gpg --import --no-default-keyring --keyring /usr/share/keyrings/release-8.gpg

sudo debootstrap --keyring=/usr/share/keyrings/release-8.gpg --foreign --verbose --arch=arm64  jessie rootfs http://archive.debian.org/debian-archive/debian/

sudo mount --bind /dev rootfs/dev/
sudo mount --bind /sys rootfs/sys/
sudo mount --bind /proc rootfs/proc/
sudo mount --bind /dev/pts rootfs/dev/pts/

sudo cp /usr/bin/qemu-aarch64-static rootfs/usr/bin/

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs /debootstrap/debootstrap --second-stage --verbose

sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs
echo deb http://archive.debian.org/debian-archive/debian jessie main > /etc/apt/sources.list
apt update
apt install build-essential

这样编译环境就搭建好了,,就可以编译aarch64下面的dropbear或nginx程序了,比交叉编译环境好用得多。

退出环境命令:

exit

sudo umount   rootfs/dev/pts/ 
sudo umount   rootfs/dev/
sudo umount   rootfs/sys/
sudo umount   rootfs/proc/

以后进入环境命令为:

cd debian8-rootfs
sudo mount --bind /dev rootfs/dev/
sudo mount --bind /sys rootfs/sys/
sudo mount --bind /proc rootfs/proc/
sudo mount --bind /dev/pts rootfs/dev/pts/
sudo LC_ALL=C LANGUAGE=C LANG=C chroot rootfs

确实比交叉编译环境好用得多。

1,制作ubuntu 20.04.5纯净版的rootfs

全ubuntu 20.04.5官网制作的纯净版,只带vi、网络、openssh等软件,也可以自己在增加。

https://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.5-base-armhf.tar.gz

下载官方包

$mkdir ubuntu
$sudo tar -xpf ubuntu-base-20.04.5-base-armhf.tar.gz -C ubuntu/
$sudo apt-get install qemu-user-static
$sudo cp /etc/resolv.conf ubuntu/etc/resolv.conf
$sudo cp /usr/bin/qemu-arm-static ubuntu/usr/bin/

修改ubuntu/etc/apt/sources.list内容如下:

deb http://repo.huaweicloud.com/ubuntu-ports/ focal main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-updates multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security main restricted
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security universe
deb http://repo.huaweicloud.com/ubuntu-ports/ focal-security multiverse
$sudo mount -o bind /proc ubuntu/proc
$sudo mount -o bind /dev ubuntu/dev
$sudo chroot ubuntu

~# apt update
~# apt install  rsyslog systemd
~# apt install  sudo htop vim bash-completion
~# apt install  ssh net-tools ethtool  ifupdown iputils-ping  network-manager

~# touch /etc/network/interfaces.d/eth0 

如果dhcp,eth0内容如下:

auto eth0
iface eth0 inet dhcp
pre-up ifconfig eth0 hw ether 10:10:10:10:10:10

如果固定ip,eth0内容如下:

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 223.5.5.5
dns-nameservers 223.6.6.6
pre-up ifconfig eth0 hw ether 10:10:10:10:10:20

ip地址根据自己情况修改。

~#echo "hi3798mv100" > /etc/hostname
~#echo "127.0.0.1 localhost" >> /etc/hosts
~#echo "127.0.0.1 hi3798mv100" >> /etc/hosts

~#ln -s /lib/systemd/system/rc-local.service  /etc/systemd/system/rc-local.service
~#echo [Install] >> /etc/systemd/system/rc-local.service
~#echo WantedBy=multi-user.target >> /etc/systemd/system/rc-local.service
~#echo Alias=rc-local.service >> /etc/systemd/system/rc-local.service

~#systemctl enable rc-local.service
~#systemctl stop motd-news.timer 
~#systemctl mask motd-news.timer 
~#systemctl stop motd-news.service
~#systemctl mask motd-news.service
~#systemctl stop networkd-dispatcher
~#systemctl mask networkd-dispatcher

修改root密码

~#passwd 

允许root远程ssh

~#echo PermitRootLogin yes >> /etc/ssh/sshd_config

~#exit

$sudo umount ubuntu/dev
$sudo umount ubuntu/proc

2,把自己做好的rootfs拷入u盘启动img镜像。
查看原img镜像分区

$ fdisk -l usb.img 
Disk usb.img: 1.84 GiB, 1973420032 bytes, 3854336 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa3008cac

Device     Boot  Start     End Sectors  Size Id Type
usb.img1   *      2048  206847  204800  100M  c W95 FAT32 (LBA)
usb.img2        206848 3854335 3647488  1.7G 83 Linux

mount img内的rootfs分区

$sudo mkdir /mnt/usb
$sudo mount -o loop,offset=xxxxx  usb.img /mnt/usb

xxxxx为上面第二个分区start值206848*512=105906176

把刚才制作好的rootfs拷贝到img里面

$sudo rm -rf /mnt/usb/*
$ sudo cp -R ubuntu/* /mnt/usb/
$ sudo umount /mnt/usb

再把usb.img 写入 U盘,,再用u盘启动华为ec6109高安版,等待几分钟后就可以ssh到ec6109,
ec6109的网卡灯有可能不亮。可以ping看系统是否启动完成。

下载openssl、pcre、zlib、nginx
$tar -zxvf openssl-1.1.1w.tar.gz
$tar -zxvf pcre-8.45.tar.gz
$tar -zxvf zlib-1.3.1.tar.gz
$tar -zxvf nginx-1.23.4.tar.gz
$cd nginx-1.23.4
$ ./configure \
--with-cc-opt='-static -static-libgcc' \
--with-ld-opt=-static \
--prefix=/opt/nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-openssl=../openssl-1.1.1w \
--with-pcre=../pcre-8.45 \
--with-zlib=../zlib-1.3.1

$ make && make install

启动
$/opt/nginx/sbin/nginx
停止
$/opt/nginx/sbin/nginx -s quit