Article From:https://www.cnblogs.com/Jimmy1988/p/9060826.html

0. background”

OpenSSHBecause it is relatively large, it is generally not suitable for embedded platforms, and is mostly used in PC or Linux versions of servers.
DropbearIt is a relatively small SSH server and client. It runs on a variety of platforms based on POSIX. Dropbear is an open source software in Massachusetts Institute of Technology style license. Dropbear is a particularly useful “embedded” Linux (or other Unix).) systems, such as wireless routers. (a complete openssh has a size of about 7M).

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

1. platform”

  • Embedded Linux platform: ARM 9
  • Embedded Linux system: TinaLinux 3.4.39
  • Host system: Ubuntu 16.04.4 LTS
  • SSHProcedure: dropbear 2016.74

Software download address:

  • zlib : http://www.zlib.net/ (PS:The 1.2.8 version used by the blogger)
  • dropbear : http://matt.ucc.asn.au/dropbear/releases/ (PS:Bloggers used 2016.74, 2018.76 version of bug, careful use, not afraid of death can try.
  • If you want to compile it all together (Bao Hanyuan files), please click here.

2. cross compilation”

Because it is necessary to compile embedded arm on host computers, the compiler should be arm.
Compiled here, including two parts: zlib and dropbear. Dropbear relies on the zlib library, so it is necessary to compile zlib first.

2.1 zlib compilation”

  • 1). Unzip zlib:
tar -zxvf zlib1.2.8.tar.gz -C /usr/local/zlib/src   (The directory here is defined according to its own situation.
  • 2). The unzip directory into the zlib
cd /usr/local/zlib/src
  • 3). Configuring zlib
./configure --prefix=/usr/local/zlib  (The library of the zlib is generated into the directory.
  • 4). The above steps are finished, and Makefile will be generated, VIM enters, and Makefile is modified.
CC=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc  //You cross compiling the absolute path of the toolAR=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc-arRANLIB=/home/BvSDK/toolchain/Bin/arm-openwrt-linux-gcc-ranlibLDSHARED=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc -shareD -Wl, -soname, libz.so.1, --version-script, zlib.map / / (I just changed the original GCC into my own compiling tool, and the parameters behind did not move).
  • 5). Execute make
  • 6). Execute make install

To complete the above steps, you can see several catalogues on behalf of zlib if you look at the /usr/local/zlib directory.

mark

2.2 dropbear compilation”

  • 1). Unzip dropbear:
tar -jxvf dropbear-2016.74.tar.bz2 -C /usr/local/dropbear/src   //(The directory here is defined according to its own situation.
  • 2). The unzip directory into the dropbear
cd /usr/local/dropbear/src
  • 3). Configuring dropbear
./configure --prefix=/usr/local/dropbear  --with-zlib=/usr/local/zlib/ CC=/home/BvSDK/toolchain/bin/arm-openwrt-linux-gcc --host=arm  //(Revised according to one's own situation.
  • 4). When the above steps are finished, the CC in Makefile will be automatically modified, and no more Makefile will be modified.
  • 5). Execute make
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" 
  • 6). Execute make install
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install
  • 7). Note that because SCP is not compiled by default, PROGRAMS=xxx compiles SCP, and it does not do so, but it needs to generate SCP by itself.
make scp  
cp scp /usr/local/dropbear

To complete the above steps, you can see several catalogues on behalf of dropbear if you look at the /usr/local/dropbear directory.

mark

3. transplant to the development board

  • The /usr/local/dropbear/bin/ is transplanted to the /usr/bin/ of the card.
  • Copy the files under /usr/local/dropbear/sbin/ to the /usr/sbin/ directory of the card.

Then the following operation is performed on the board:

cd /etc
mkdir dropbear      //The name is fixed and must not be changedCD dropbearDropbearkey -t RSA -f dropbear_rsa_host_keyDropbearkey -t DSS -f dropbeAr_dss_host_key

4. embedded system configuration

Now that we have finished dropbear, we certainly hope that it can boot up. No one wants to start this thing manually at any time.

4.1 start the boot step:

cd /etc/init.d/
touch dropbear_autorun

//Add the following content to the dropbear_autorun file/bin/sh /etc/rc.commonCopyright (C) 2006 OpenWrt.orgSTART=99Start() {CD /usr/sbin/./dropbearCD -}/ / then link the file to the rc.dCD /etc/rc.d/Ln -s../init.d/dropbear_autorun S99dropbear

4.2 new account or set password for root.

Because SSH requires that there must be a password, if a new user can be added to the card, a new user can be added directly.

useradd admin
passwd admin

But my card does not allow other users to be created. I can only give root password, otherwise SSH will not be able to login.

5. problem”

  • 1). If other hosts SCP, SSH to the board have problems, you can try to move the files under the /usr/sbin/, /usr/bin/, and /sbin/ directories, and then try again to see if there is the same problem (I won’t tell you I’m stuck on this problem. “For a long time)
  • 2). scpIt needs to be transplanted to /usr/bin/. Otherwise, other hosts can not push SCP files to the card.
-ash: scp: not found
lost connection
  • 3). The execution of dropbear in the board is not responsive

    Reason 1: did not execute dropbearkey, or executed no key file.
    The reason is that the 2:key file is not in the /etc/dropbear/ file. The directory name is fixed and cannot be changed.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *