版权声明:转载请附带原博主的网址 https://blog.csdn.net/qq_43260665/article/details/89740503
1,下载dropbear源码包,解压进入:
zhanghang@ubuntu:~/fl2440/linux$ wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2016.74.tar.bz2
zhanghang@ubuntu:~/fl2440/linux$ tar -xjf dropbear-2016.74.tar.bz2
zhanghang@ubuntu:~/fl2440/linux$ cd dropbear-2016.74/
zhanghang@ubuntu:~/fl2440/linux$ mkdir dropbear
zhanghang@ubuntu:~/fl2440/linux$ cd dropbear-2016.74/
zhanghang@ubuntu:~/fl2440/linux/dropbear-2016.74$ ./configure --prefix=`pwd`/../dropbear/
...
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether __UCLIBC__ is declared... no
checking for crypt... no
checking for crypt in -lcrypt... yes
checking for deflate in -lz... no
configure: error: *** zlib missing - install first or check config.log ***
报错缺失zlib库,安装zlib库:
可以直接安装:
zhanghang@ubuntu:~/fl2440/linux/dropbear-2016.74$ sudo apt-get install libz-dev
如果不行,也可以这样:
zhanghang@ubuntu:~/fl2440/linux$ sudo mkdir zlib
zhanghang@ubuntu:~/fl2440/linux$ wget https://github.com/madler/zlib/archive/v1.2.10.tar.gz -O zlib-1.2.10.tar.gz
zhanghang@ubuntu:~/fl2440/linux$ tar -xzf zlib-1.2.10.tar.gz
zhanghang@ubuntu:~/fl2440/linux$ cd zlib-1.2.10/
zhanghang@ubuntu:~/fl2440/linux/zlib-1.2.10$ ./configure --prefix=`pwd`/../zlib/ --static
修改Makefile文件:
zhanghang@ubuntu:~/fl2440/linux/zlib-1.2.10$ vim Makefile
19 CC=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc
30 LDSHARED=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc
31 CPP=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc -E
39 AR=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-ar
zhanghang@ubuntu:~/fl2440/linux/zlib-1.2.10$ sudo make && make install
切换到dropbear开发包路径下:
zhanghang@ubuntu:~/fl2440/linux/dropbear-2016.74$ ./configure --prefix=`pwd`/../dropbear --with-zlib=`pwd`/../zlib/
修改Makefile文件的CC=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc
以上两部可以合并为:
./configure --prefix=`pwd`/../dropbear --with-zlib=`pwd`/../zlib/ CC=/opt/xtools/arm920t/bin/arm-arm920t-linux-gnueabi-gcc --host=arm
最后:
zhanghang@ubuntu:~/fl2440/linux/dropbear-2016.74$ make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
zhanghang@ubuntu:~/fl2440/linux/dropbear-2016.74$ make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install
接下来现在将dropbear文件夹下的sbin和bin下的所有文件传到windows下,在开发板上使用tftp -gr命令将这些文件传到开发板的sbin路径下
~ >: tftp -gr dbclient 192.168.2.8
~ >: tftp -gr dropbear 192.168.2.8
~ >: tftp -gr dropbearconvert 192.168.2.8
~ >: tftp -gr dropbearkey 192.168.2.8
~ >: tftp -gr scp 192.168.2.8
~ >: mv dbclient dropbear dropbearconvert dropbearkey scp sbin
给他们可执行权限:
/sbin >: chmod a+x dbclient dropbear dropbearconvert dropbearkey scp
扫描二维码关注公众号,回复:
6107423 查看本文章
![](/qrcode.jpg)
~ >: cd etc/
~ >: mkdir dropbear
/etc >: cd dropbear/
/etc/dropbear >: dropbearkey -t rsa -f dropbear_rsa_host_key
/etc/dropbear >: dropbearkey -t dss -f dropbear_dss_host_key
/etc/dropbear >: ls
dropbear_dss_host_key dropbear_rsa_host_key
在etc/init.d下添加启动脚本:
/etc/init.d >: vim S11_dropbear
#!/bin/sh
/sbin/dropbear
/etc/init.d >: chmod a+x S11_dropbear
执行dropbear:
/sbin >: ./dropbear
/sbin >: netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 972/dropbear
可以看到22号端口(ssh端口已经打开),此时就可以通过ssh登录开发板了:
~ >: ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:3E:26:0A:5B
inet addr:192.168.2.168 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1889 errors:0 dropped:0 overruns:0 frame:0
TX packets:1825 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1008547 (984.9 KiB) TX bytes:84906 (82.9 KiB)
Interrupt:51 Base address:0x6300
成功登录!
也可以在制作根文件系统时直接进行上面所有操作,这样制作的根文件系统会自带dropbear。