[Reserved] Embedded Linux transplantation Dropbear SSH server

0.5 Background

 OpenSSH because of its relatively large, generally less suitable for embedded platforms, multi-version for Linux 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, at MIT-style license. Dropbear is particularly useful for "embedded" in Linux (or other Unix) systems, such as wireless router. (There is a full size openssh 7M or so).

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

1. Software Download

2. cross compiler

Because of the need to compile things embedded in the arm on the host, so the compiler should be arm's.
Here compilation consists of two parts: zlib and dropbear. dropbear rely on zlib library, it must be compiled before they can zlib.

2.1 zlib compilation

  • 1) extract the zlib:
tar -zxvf zlib1.2.8.tar.gz -C /usr/local/zlib/src   (此处目录根据自己情况定义)
  • 2) Access zlib decompression directory
cd /usr/local/zlib/src
  • 3) Configuration zlib
./configure --prefix=/usr/local/zlib  (即将zlib的库生成到该目录下)  
  • 4) The above step is done, will generate Makefile, into Vim, 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) The Executive make
  • 6) The Executive make install

Completing the above steps, you go to look under / usr / local / zlib directory, you will find more than a few directories, on behalf of zlib cross compiler success! !

2.2 dropbear compilation

  • 1) extracting dropbear:
tar -jxvf dropbear-2016.74.tar.bz2 -C /usr/local/dropbear/src   //(此处目录根据自己情况定义)
  • 2). Dropbear decompression into the directory
cd /usr/local/dropbear/src
  • 3) Configuration 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 steps done, CC in the Makefile will automatically modify out, people do not have to modify the Makefile
  • 5) The Executive make
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" 
  • 6) The Executive 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 scp, also can not do that way, but you need to generate their own scp:
make scp  
cp scp /usr/local/dropbear

Completing the above steps, you go to look under / usr / local / dropbear directory, you will find more than a few directories, on behalf of dropbear cross compiler success! !

3. transplanted into boards

  • The / usr / local / dropbear / bin / transplanted into boards / usr / bin / lower;
  • The files in / usr / local / dropbear / sbin / are copied to the board / usr / sbin / directory

Then the board to perform the following operations:

cd /etc
mkdir dropbear      //这个名字是固定的,千万不可变动
cd dropbear
dropbearkey -t rsa -f dropbear_rsa_host_key
dropbearkey -t dss -f dropbear_dss_host_key

4. Embedded System Configuration

Now that somehow dropbear, we certainly hope that it can boot myself, who do not want to manually start each time you turn on this thing right! ! !

4.1 boot steps:

cd /etc/init.d/
touch dropbear_autorun

//将下面内容加入到dropbear_autorun文件
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=99
start() {
        cd /usr/sbin/
        ./dropbear
        cd -
}

//然后将该文件链接到rc.d中
cd /etc/rc.d/
ln -s ../init.d/dropbear_autorun S99dropbear

4.2 new account or give root password

Because SSH requirements must have a password, so if you can add new users on board, you can directly add a new user:

useradd admin
passwd admin

But my board does not allow other users, only a password assigned to the root, or SSH could not land

5. issue

  • 1) If the other host scp, ssh to the board there is a problem, you can try to file / move under / usr / bin / and / sbin / directory / usr / sbin, then test again to see if the same problem occur
  • . 2) scp need to migrate to / usr / bin / under, or other hosts may not scp files to push this card, the following error:
-ash: scp: not found
lost connection
  • 3). Dropbear performed board did not respond
原因1:没有执行dropbearkey, 或者执行了没生成key文件
原因2:key文件不在/etc/dropbear/文件中,这个目录名称是固定死的,不可更改
  • Reprinted from above: www.cnblogs.com/Jimmy1988/p/9060826.html, thank bloggers!
I am in the choice of the source, all of the appropriate download the latest version, and with reference to the above steps, the final success of the transplant Dropbear.

0.5 Background

 OpenSSH because of its relatively large, generally less suitable for embedded platforms, multi-version for Linux 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, at MIT-style license. Dropbear is particularly useful for "embedded" in Linux (or other Unix) systems, such as wireless router. (There is a full size openssh 7M or so).

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

1. Software Download

2. cross compiler

Because of the need to compile things embedded in the arm on the host, so the compiler should be arm's.
Here compilation consists of two parts: zlib and dropbear. dropbear rely on zlib library, it must be compiled before they can zlib.

2.1 zlib compilation

  • 1) extract the zlib:
tar -zxvf zlib1.2.8.tar.gz -C /usr/local/zlib/src   (此处目录根据自己情况定义)
  • 2) Access zlib decompression directory
cd /usr/local/zlib/src
  • 3) Configuration zlib
./configure --prefix=/usr/local/zlib  (即将zlib的库生成到该目录下)  
  • 4) The above step is done, will generate Makefile, into Vim, 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) The Executive make
  • 6) The Executive make install

Completing the above steps, you go to look under / usr / local / zlib directory, you will find more than a few directories, on behalf of zlib cross compiler success! !

2.2 dropbear compilation

  • 1) extracting dropbear:
tar -jxvf dropbear-2016.74.tar.bz2 -C /usr/local/dropbear/src   //(此处目录根据自己情况定义)
  • 2). Dropbear decompression into the directory
cd /usr/local/dropbear/src
  • 3) Configuration 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 steps done, CC in the Makefile will automatically modify out, people do not have to modify the Makefile
  • 5) The Executive make
make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" 
  • 6) The Executive 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 scp, also can not do that way, but you need to generate their own scp:
make scp  
cp scp /usr/local/dropbear

Completing the above steps, you go to look under / usr / local / dropbear directory, you will find more than a few directories, on behalf of dropbear cross compiler success! !

3. transplanted into boards

  • The / usr / local / dropbear / bin / transplanted into boards / usr / bin / lower;
  • The files in / usr / local / dropbear / sbin / are copied to the board / usr / sbin / directory

Then the board to perform the following operations:

cd /etc
mkdir dropbear      //这个名字是固定的,千万不可变动
cd dropbear
dropbearkey -t rsa -f dropbear_rsa_host_key
dropbearkey -t dss -f dropbear_dss_host_key

4. Embedded System Configuration

Now that somehow dropbear, we certainly hope that it can boot myself, who do not want to manually start each time you turn on this thing right! ! !

4.1 boot steps:

cd /etc/init.d/
touch dropbear_autorun

//将下面内容加入到dropbear_autorun文件
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org

START=99
start() {
        cd /usr/sbin/
        ./dropbear
        cd -
}

//然后将该文件链接到rc.d中
cd /etc/rc.d/
ln -s ../init.d/dropbear_autorun S99dropbear

4.2 new account or give root password

Because SSH requirements must have a password, so if you can add new users on board, you can directly add a new user:

useradd admin
passwd admin

But my board does not allow other users, only a password assigned to the root, or SSH could not land

5. issue

  • 1) If the other host scp, ssh to the board there is a problem, you can try to file / move under / usr / bin / and / sbin / directory / usr / sbin, then test again to see if the same problem occur
  • . 2) scp need to migrate to / usr / bin / under, or other hosts may not scp files to push this card, the following error:
-ash: scp: not found
lost connection
  • 3). Dropbear performed board did not respond
原因1:没有执行dropbearkey, 或者执行了没生成key文件
原因2:key文件不在/etc/dropbear/文件中,这个目录名称是固定死的,不可更改

Guess you like

Origin www.cnblogs.com/GyForever1004/p/11922240.html