dropbear(面向嵌入式linux os 的shh)移植

iMX6UL平台移植和测试dropbear过程记录

事实上如果你的核心板的flash容量有4G ,8G或是更多,直接应用freescale官方的rootfs,里面集成很多有用的工具,无需自己移植。但是如果flash容量有限,而不得不应用一个精简的文件系统,有一个有大局观的考量很重要,你需要把客户的基本需求和预期需求加进去,不然对一个很加入团队的人来说,接手前人的工作,今天根据客户的这个要求加点功能,明天再根据其他的要求加点功能,不管是针对u-boot/kernel/还是文件系统,都是一件让人头疼的是事。言归正传,写笔记如下:

1.dropbear 版本:dropbear-2014.66&dropbear-2015.71 都ok。
2.详细阅读INSTALL

3.编译过程:(在我的linux 编译服务器,OS :Ubuntu14.04)

source ~/autoscripts/export_env.sh

脚本内容如下:


export CROSS_PREFIX=/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/arm-none-linux-gnueabi-
export install_dir=/home/diskf/home/hyj/cross_compile/dropbear-2014.66/ssh-install
./configure --host=arm-none-linux-gnueabi --build=x86_64-linux-gnu --prefix=$install_dir --disable-zlib

make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" STATIC=0

注:static=1时,在开发板上生成密钥时出错。

make install
cp scp ./ssh-install/bin/
make strip
说明:
dbclient          作为客户用来连接服务器的,相当于ssh。
dropbear          服务器端监听端口的,相当于sshd。
dropbearkey       用来生成密钥,没有密钥的dropbear不能提供服务。
dropbearconvert   不太清楚
4.打包 
fakeroot tar -cvjf ssh-install.tar.bz ssh-install
5.移植到开发板
1.) 导出环境变量(没有部署到文件系统时的测试步骤)
export PATH=/root/ssh-install/bin:/root/ssh-install/sbin:$PATH
2.)生成密钥
mkdir /etc/dropbear
cd /etc/dropbear/
dropbearkey -t rsa -f dropbear_rsa_host_key
dropbearkey -t dss -f dropbear_dss_host_key
3.)开启dropbear服务
vi /etc/rc.d/rc.local  合适的位置添加如下行:
/root/ssh-install/sbin/dropbear
4.)修改root用户密码(否则无法通过ssh登陆开发板)
 passwd root 
   按提示输入即可
5.)配置开发板IP和网关 如:
ifconfig eth1 192.168.x.xxx
route add gw 192.168.x.x dev eth1
6.测试dropbear
1.) 测试由linux主机通过ssh访问开发板
hyj@developer-RH2485-V2:~/cross_compile/dropbear-2014.66$ ssh [email protected]
[email protected]'s password:
root@freescale ~$
2.)测试由Windows主机通过putty访问开发板
 login as: root
 [email protected]'s password:
 root@freescale ~$
3.)由开发板访问linux主机
root@freescale ~$ dbclient [email protected]
[email protected]'s password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-31-generic x86_64)
 * Documentation:  https://help.ubuntu.com/
New release '16.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Tue Mar 13 13:32:24 2018 from 192.168.2.232
hyj@developer-RH2485-V2:~$
4.)验证从开发板通过 scp 拷贝文件到linux主机
root@freescale ~$ ln -s /root/ssh-install/bin/dbclient /usr/bin/dbclient
root@freescale ~$ /root/ssh-install/bin/scp test.txt [email protected]:/home/diskf/home/hyj/cross_compile/dropbear-2014.66/
[email protected]'s password:
从linux主机端验证文件传是否被正常接收
hyj@developer-RH2485-V2:~/cross_compile/dropbear-2014.66$ ls -l tes*
-rw-r--r-- 1 hyj imx6ul 1  3月 13 14:09 test.txt
**********************************************
开发板秘钥修改后,在服务器端删除如下文件再重新连接即可
/home/diskf/home/hyj/.ssh/known_hosts
**********************************************
scp [email protected]:/home/diskf/home/hyj/imx6ul/linux-3.14.38/arch/arm/boot/zImage ./

猜你喜欢

转载自blog.csdn.net/hanpca/article/details/80279862
今日推荐