嵌入式linux轻量级sshd服务工具Dropbear移植
嵌入式linux轻量级sshd服务工具Dropbear移植
- 介绍
- 编译流程
- 1. 编译zlib
- 2. 编译dropbear
- 3. 移植
- 4. 运行
- 5. 移植sftp-server
介绍
往往考虑到嵌入式系统内存空间小的问题,生成的dropbear大小只有几百kb的大小,所以经常适用于嵌入式系统。需要注意的是dropbear只能使用scp上传文件, 不能使用sftp,若需要支持sftp,还需要用openssl编译生成的sftp-server来支持sftp。
编译流程
dropbear源码:https://matt.ucc.asn.au/dropbear/dropbear.html
zlib源码: http://zlib.net/
1. 编译zlib
#表示注释
$表示命令行
# 下载源码
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ tar -zxvf zlib-1.2.11.tar.gz# 创建安装目录install
$ mkdir install
$ ls
install zlib-1.2.11 zlib-1.2.11.tar.g
$ cd zlib-1.2.11# 查看帮助文档
$ ./configure --help
usage:configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX][--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR][--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]
# 这里并没有提示类似--host,--cross_complie之类方便指定交叉编译工具链的选项
# --prefix=PREFIX 指定安装路径
# --static 编译静态库, 注意这里最好编译动态库,不要选--static
# 编译静态库时,在后面配置dropbear时可能会报"checking for deflate in -lz... no"这样的错误
# ./configure --prefix=`pwd`/../install --static# 编译动态库
$ ./configure --prefix=`pwd`/../install# 运行configure之后,打开生成的makefile,可以从中找到关键的CC,CPP这些和交叉编译有关的地方,修改成自己的交叉编译工具,如
# CC=arm-linux-gcc
# CPP=arm-linux-gcc -E
# AR=arm-linux-ar
# RANLIB=arm-linux-ranlib
# LDSHARED=arm-linux-gcc
# 注意在make之前要将交叉编译工具的路径添加到当前的shell环境中,可以命令export=$PATH:交叉编译工具的路径
# 或者使用厂家提供的sdk中的source来设置交叉编译工具的环境,如果先用这种方式设置环境,再使用configure,一般都不必再修改Makefile了# 编译和安装
make
make install# 编译安装结果
$ ls ../install/
include lib share
2. 编译dropbear
#表示注释
$表示命令行
# 下载源码
$ wget https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2# 解压
$ tar -jxvf dropbear-2020.81.tar.bz2# 创建安装路径
mkdir install
$ ls
install dropbear-2020.81 dropbear-2020.81.tar.bz2
$ cd dropbear-2020.81
# 查看编译帮助文档
$ ./configure --help
`configure' configures this package to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help display this help and exit--help=short display options specific to this package--help=recursive display the short help of all the included packages-V, --version display version information and exit-q, --quiet, --silent do not print `checking ...' messages--cache-file=FILE cache test results in FILE [disabled]-C, --config-cache alias for `--cache-file=config.cache'-n, --no-create do not create output files--srcdir=DIR find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR user executables [EPREFIX/bin]--sbindir=DIR system admin executables [EPREFIX/sbin]--libexecdir=DIR program executables [EPREFIX/libexec]--sysconfdir=DIR read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR modifiable single-machine data [PREFIX/var]--libdir=DIR object code libraries [EPREFIX/lib]--includedir=DIR C header files [PREFIX/include]--oldincludedir=DIR C header files for non-gcc [/usr/include]--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]--datadir=DIR read-only architecture-independent data [DATAROOTDIR]--infodir=DIR info documentation [DATAROOTDIR/info]--localedir=DIR locale-dependent data [DATAROOTDIR/locale]--mandir=DIR man documentation [DATAROOTDIR/man]--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]--htmldir=DIR html documentation [DOCDIR]--dvidir=DIR dvi documentation [DOCDIR]--pdfdir=DIR pdf documentation [DOCDIR]--psdir=DIR ps documentation [DOCDIR]System types:--build=BUILD configure for building on BUILD [guessed]--host=HOST cross-compile to build programs to run on HOST [BUILD]Optional Features:--disable-option-checking ignore unrecognized --enable/--with options--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG] include FEATURE [ARG=yes]--enable-static Build static binaries--disable-harden Don't set hardened build flags--disable-largefile omit support for large files--disable-zlib Don't include zlib support--enable-pam Try to include PAM support--disable-openpty Don't use openpty, use alternative method--disable-syslog Don't include syslog support--disable-shadow Don't use shadow passwords (if available)--enable-plugin Enable support for External Public Key Authentication plug-in--enable-fuzz Build fuzzing. Not recommended for deployment.--enable-bundled-libtom Force using bundled libtomcrypt/libtommath even if a system version exists.--disable-bundled-libtom Force using system libtomcrypt/libtommath, fail if it does not exist.Default is to use system if available, otherwise bundled.Dropbear requires system libtommath >= 1.2.0 and libtomcrypt >= 1.18.0--disable-lastlog Disable use of lastlog even if detected no--disable-utmp Disable use of utmp even if detected no--disable-utmpx Disable use of utmpx even if detected no--disable-wtmp Disable use of wtmp even if detected no--disable-wtmpx Disable use of wtmpx even if detected no--disable-loginfunc Disable use of login() etc. no--disable-pututline Disable use of pututline() etc. (uwtmp) no--disable-pututxline Disable use of pututxline() etc. (uwtmpx) noOptional Packages:--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)--with-zlib=PATH Use zlib in PATH--with-pam=PATH Use pam in PATH--with-lastlog=FILE|DIR specify lastlog location common locationsSome influential environment variables:CC C compiler commandCFLAGS C compiler flagsLDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS libraries to pass to the linker, e.g. -l<library>CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CPP C preprocessorCXX C++ compiler commandCXXFLAGS C++ compiler flagsUse these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.Report bugs to the package provider.# 配置
# configure --prefix=安装路径 --host=arm CC=交叉编译链gcc名称 --with-zlib=zlib安装路径
# 安装路径最后使用绝对路径
$ ./configure --prefix=/opt/dropbear/install --host=arm CC=arm-linux-gcc --with-zlib=/opt/zlib/install# 编译
$ make
$ make scp
# 编译出来的scp在dropbear的源码目录下,而非安装--prefix=/opt/dropbear/install目录下
$ make install# 注,编译完成后可以使用arm-linux-strip工具去除调试信息, 对.so同样适用, 这样优化后能减小文件大小,对嵌入式系统很有用, 比如:
$ arm-linux-strip scp
3. 移植
- 将scp复制到/usr/bin
- 将/opt/dropbear/install下的文件复制到相应的/usr/bin, /usr/sbin下面
- 在/etc目录下面创建dropbear,注意这一个目录一定要有
mkdir -p /etc/dropbear
4. 运行
#表示注释
$表示命令行
# 查看版本及命令
$ /usr/sbin/dropbear -V
$ /usr/sbin/dropbear -h# 需要注意一个选项-R, 使用这个选项可以不必立刻生成hostkey,会在需要的时候自动生成
# 运行,为了方便,最好添加到自启动中, 自启动的方法就不这里赘述了
$ /usr/sbin/dropbear -R# 也可以先生成dropbear_rsa_host_key, 放到/etc/dropbear/下, 生成一次就够了
$ dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key
$ dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key
# 运行
$ /usr/sbin/dropbear
5. 移植sftp-server
源码地址:https://www.openssh.com/portable.html
# 下载
$ wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.6p1.tar.gz
$ tar -zxvf openssh-8.6p1.tar.gz
$ mkdir install
$ cd openssh-8.6p1
# ./configure --host=arm-linux --with-zlib=zlib安装路径
$./configure --host=arm-linux --with-zlib=/opt/zlib/install# 编译sft-server
make sftp-server# 利用arm-linux-strip减小sftp-server文件大小
$ arm-linux-strip sftp-server# 利用arm-linux-readelf查看sftp-server的依赖库
# arm-linux-readelf -d sftp-server
Dynamic section at offset 0x1dc60 contains 29 entries:Tag Type Name/Value0x00000003 (PLTGOT) 0x1edb80x00000002 (PLTRELSZ) 1144 (bytes)0x00000017 (JMPREL) 0x17c40x00000014 (PLTREL) REL0x00000011 (REL) 0x13640x00000012 (RELSZ) 1120 (bytes)0x00000013 (RELENT) 8 (bytes)0x6ffffffa (RELCOUNT) 1310x00000015 (DEBUG) 0x00x00000006 (SYMTAB) 0x1cc0x0000000b (SYMENT) 16 (bytes)0x00000005 (STRTAB) 0xb5c0x0000000a (STRSZ) 1553 (bytes)0x6ffffef5 (GNU_HASH) 0x11700x00000001 (NEEDED) Shared library: [libcrypto.so.1.0.0]0x00000001 (NEEDED) Shared library: [libc.so.6]0x00000001 (NEEDED) Shared library: [ld-linux.so.3]0x0000000c (INIT) 0x1c3c0x0000000d (FINI) 0x19c540x00000019 (INIT_ARRAY) 0x1ec540x0000001b (INIT_ARRAYSZ) 4 (bytes)0x0000001a (FINI_ARRAY) 0x1ec580x0000001c (FINI_ARRAYSZ) 4 (bytes)0x0000001e (FLAGS) BIND_NOW0x6ffffffb (FLAGS_1) Flags: NOW0x6ffffff0 (VERSYM) 0x11a00x6ffffffe (VERNEED) 0x12d40x6fffffff (VERNEEDNUM) 30x00000000 (NULL) 0x0
将sftp-server复制到开发板的/usr/libexec/目录下, 同时将sftp-server以来的库复制到/usr/lib/目录下
嵌入式linux轻量级sshd服务工具Dropbear移植相关推荐
- Linux 之八 完整嵌入式 Linux 环境及构建工具、(交叉)编译工具链、CPU 体系架构
最近,工作重心要从裸机开发转移到嵌入式 Linux 系统开发,由于之前对嵌入式 Linux 环境并不是很了解,因此,第一步就是需要了解如何搭建一个完整的嵌入式 Linux 环境.现在将学习心得记录 ...
- L1D1:嵌入式Linux C语言开发工具及基础命令
嵌入式Linux C语言开发工具及基础命令 一.ubuntu环境搭建 请自行准备VMware workstation15安装包 及 ubuntu18.04.iso镜像文件.可参考链接:VMware W ...
- 嵌入式Linux系统中打印机驱动的移植
一.开发环境 硬件环境:DM365 打印机型号:HP P1007 虚拟机系统:Red Hat Enterprise Linux 5 交叉编译环境:Ti交叉编译环境安装包 二.详细步骤 1.下载Ghos ...
- 嵌入式Linux添加ssh服务
嵌入式Linux安装Dropbear 开发环境 嵌入式Linux平台: ARM 7 (IMX6ULL) 嵌入式Linux内核版本:4.1.15 宿主系统: Ubuntu 16.04 LTS SSH程序 ...
- 嵌入式Linux全攻略 ACE程序移植过程详细讲解
2019独角兽企业重金招聘Python工程师标准>>> 1.在安装有Linux操作系统的PC上安装交叉编译器,笔者使用的是Moxa tool chain for DA66x,(其它的 ...
- 嵌入式Linux入门2:工具掌握(Windows篇)
学习嵌入式Linux过程中会使用到各式不同的软件工具.本文就介绍在Windows系统下使用的工具,但不会深入,只作大纲式的列举工具. 一.综合类 1.思维导图 思维导图是一种图像式思维的工具以及一种利 ...
- 嵌入式linux文件系统缺少flash_eraseall工具
背景: 1.嵌入式linux开发,进行镜像升级功能,发现没有flash擦除工具. 2.文件系统下的工具通过busybox生成. 解决方案: 重新配置和编译busybox. 1.修改.config文件. ...
- Linux下 sshd服务不能启动
今天遇到CentOS 7 下远程连不上,怀疑服务没有启动,先检查了端口和服务是否启动: ps -A| grep sshd 发现没有 netstat -nultp|grep 22 也没有发现22端口 检 ...
- 嵌入式Linux开发板_WIFI无线网卡驱动移植
在线课堂:https://www.100ask.net/index(课程观看) 论 坛:http://bbs.100ask.net/(学术答疑) 开 发 板:https://100ask.taoba ...
最新文章
- Nessus更新到8.5.0
- 信息安全培训的一些考题和答案
- ERROR: Unrecognized command line argument: #39;use#39;
- 一个女人不收拾厨房,卫生间便池也不刷,为什么老公也不嫌弃?
- 迭代器适配器{(插入迭代器back_insert_iterator)、IO流迭代器(istream_iterator、ostream_iterator)}...
- 危险!请马上替换代码中的BeanUtils!!!
- 智慧灯杆供电系统设计要求
- MicroSip客户端编译、运行
- mysql默认的锁_mysql默认是悲观锁还是乐观锁
- web前端技术——三、表单
- 双 JK 触发器 74LS112 逻辑功能。真值表_触发器的工作原理是什么
- ThingsBoard使用规则链将设备信息转发至外部mqtt
- 手写杀毒软件——放心的安全卫士
- 贪心算法解题报告(D-Farmer John)
- 什么是贝叶斯网络?原理入门
- 如何将本地的项目推送至git仓库
- Seqlist 代码
- 如何用人工智能秒杀超级马里奥游戏
- One UI 5 升级来了
- 【Cocos2d-x 游戏开发】HttpClient制作网络游戏
热门文章
- redis 主从 哨兵 集群 及原理
- Unity3d--改进飞碟游戏 作业6
- Tryhackme-Malware Analysis
- 小凯的疑惑(扩展欧几里得)
- 马扎克 MAZAK CNC数据采集smart、smooth(smooth-c、smooth-g、smooth-x)、matrix(nexu、nexu2)以及640(640m、640mn、640t)系列
- 国内BIM案例VS国外BIM案例
- 唯众模块化物联网技术综合实训装置的设计与实现
- Axiom3D学习日记 0.Axiom基础知识
- 什么是开源生态?———— 《硅谷生态圈》书评
- 智慧养老之基于RFID技术下的智慧养老解决方案-养老院智能看护系统-新导智能