Embedded Linux installation dropbear SSH server

Source: Internet
Author: User
Tags ssh server dropbear

Tag: Serve block tells the completion of the HTM prefix lin settings dropbear

0. Background

OpenSSH because it is relatively large, it is generally not suitable for the embedded platform, and is used in the Linux version of the PC or server.
Dropbear is a relatively small SSH server and client. It runs on a variety of POSIX-based platforms. Dropbear is open source software, a MIT-style license. Dropbear is a particularly useful "embedded" type of Linux (or other Unix) system, such as a wireless router. (a full openssh size is around 7M).

Reference: https://matt.ucc.asn.au/dropbear/dropbear.html

1. Platform
  • Embedded Linux platforms: ARM 9
  • Embedded Linux systems: Tinalinux 3.4.39
  • Host System: Ubuntu 16.04.4 LTS
  • SSH Program: dropbear 2016.74

Software:

  • zlib:http://www.zlib.net/(PS: 1.2.8 version for bloggers)
  • Dropbear:http://matt.ucc.asn.au/dropbear/releases/(PS: Bo main use of 2016.74, 2018.76 version has a bug, cautious use, not afraid of death can try)
2. Cross-compiling

Because of the need to compile embedded arm stuff on the host, the compiler should be arm.
Compiled here, including two sections: Zlib and Dropbear. Dropbear relies on zlib libraries, so you must compile zlib before you can.

2.1 zlib Compilation
  • 1). Unzip the zlib:
tar -zxvf zlib1.2.8.tar.gz -C /usr/local/zlib/src   (此处目录根据自己情况定义)
  • 2). Enter the Zlib directory
cd /usr/local/zlib/src
  • 3). Configure Zlib
./configure --prefix=/usr/local/zlib  (即将zlib的库生成到该目录下)  
  • 4). The above step is done, will generate makefile,vim in, modify the makefile
CC=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc  //你交叉编译工具的绝对路径  AR=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc-ar  RANLIB=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc-ranlib    LDSHARED=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc -shared   -Wl,-soname,libz.so.1,--version-script,zlib.map   //(我只是将原来的gcc改成了我自己的编译工具,后面的参数没动过)
  • 5). Execute Make
  • 6). Execute make Install

Complete the above steps, you go to the/usr/local/zlib directory, you will find a few more directories, on behalf of Zlib Cross-compiling success!!

2.2 Dropbear Compilation
  • 1). Unzip the Dropbear:
tar -jxvf dropbear-2016.74.tar.bz2 -C /usr/local/dropbear/src   //(此处目录根据自己情况定义)
  • 2). Enter the Dropbear directory
cd /usr/local/dropbear/src
  • 3). Configure Dropbear
./configure --prefix=/usr/local/dropbear  --with-zlib=/usr/local/zlib/ CC=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc --host=arm  //(根据自己的情况修改)
  • 4). The above step is done, CC in Makefile will be changed automatically, no need to modify makefile.
  • 5). Execute Make
  • 6). Execute make Install
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install
  • 7). Note that because the default does not compile scp,programs=xxx is forced to compile the SCP, it is not possible to do so, but you need to generate the SCP yourself:
make scp  cp scp /usr/local/dropbear

Complete the above steps, you go to the/usr/local/dropbear directory, you will find a few more directories, on behalf of Dropbear Cross-compiling success!!

3. Porting to the Development Board
  • The/usr/local/dropbear/bin/is transplanted to the/usr/bin/of the Board;
  • Copy the files under/usr/local/dropbear/sbin/to the/usr/sbin/directory on the board

Then go to the board and do the following:

cd /etcmkdir dropbear      //这个名字是固定的,千万不可变动cd dropbeardropbearkey -t rsa -f dropbear_rsa_host_keydropbearkey -t dss -f dropbear_dss_host_key
4. Embedded System Configuration

Now that we have the dropbear, we must hope that it can start the boot, who would not want to boot in the manual to start this thing!!!

4.1 Boot start Step:
cd /etc/init.d/touch dropbear_autorun//将下面内容加入到dropbear_autorun文件#!/bin/sh /etc/rc.common# Copyright (C) 2006 OpenWrt.orgSTART=99start() {        cd /usr/sbin/        ./dropbear        cd -}//然后将该文件链接到rc.d中cd /etc/rc.d/ln -s ../init.d/dropbear_autorun S99dropbear
4.2 Create a new account or set a password to root

Because SSH requires a password, you can add a new user directly if a new user is added to the board:

useradd adminpasswd admin

But my card is not allowed to set up other users, can only give root password, or SSH can not login

5. Questions
  • 1). If there is a problem with the other host SCP, SSH to the board, you can try to move the files in the/usr/sbin/,/usr/bin/, and/sbin/directories, and then experiment again to see if the same problem occurs (I will not tell you that I am stuck on this issue for a long time)
  • 2). SCP needs to be ported to/usr/bin/, otherwise the other hosts will not be able to push files to this board in SCP, the following error occurred:
-ash: scp: not foundlost connection
  • 3). Board execution Dropbear Not responding

    Cause 1: No dropbearkey executed, or no key file was executed
    Cause the 2:key file is not in the/etc/dropbear/file, the directory name is fixed dead and cannot be changed

Embedded Linux installation dropbear SSH server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.