zoukankan      html  css  js  c++  java
  • 基于 Dropbear & Zlib 搭建轻量级的ssh server

    【目的】

    移植dropbear & zlib 在AM335X开发板上搭建轻量级的ssh server

    【环境】

    1、  Ubuntu 16.04发行版

    2、  MC183平台

    3、  交叉编译器arm-linux-gnueabihf-gcc-4.7.3

    【步骤】

    1、下载zlib-1.2.8.tar.gz dropbear-2015.67.tar.bz2源码。

    2.  交叉编译zlib。

    解压zlib-1.2.8.tar.gz

    tar zvxf  zlib-1.2.8.tar.gz

    cd zlib-1.2.8

    配置:

    ./configure  --prefix=../../zlib/install

    修该Makefile用于交叉编译,如下加粗字体为改动部分:

    change Makefile

     

    CROSS=arm-linux-gnueabihf-

    CC=$(CROSS)gcc

     

    CFLAGS=-O3  -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN

    #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7

    #CFLAGS=-g -DDEBUG

    #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion

    #           -Wstrict-prototypes -Wmissing-prototypes

     

    SFLAGS=-O3  -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN

    LDFLAGS=

    TEST_LDFLAGS=-L. libz.a

    LDSHARED=$(CC) -shared -Wl,-soname,libz.so.1,--version-script,zlib.map

    CPP=$(CC) -E

     

    STATICLIB=libz.a

    SHAREDLIB=libz.so

    SHAREDLIBV=libz.so.1.2.8

    SHAREDLIBM=libz.so.1

    LIBS=$(STATICLIB) $(SHAREDLIBV)

     

    AR=$(CROSS)ar

    ARFLAGS=rc

    RANLIB=$(CROSS)ranlib

    LDCONFIG=ldconfig

    LDSHAREDLIBC=-lc

    TAR=tar

    SHELL=/bin/sh

    EXE=

     

    #prefix =/usr/local

    prefix=../../zlib/install

     

    编译:

    make

    安装到prefix目录当中:

    make install

     

    用tree 显示安装目录如下所示:

    install

    ├── include

    │   ├── zconf.h

    │   └── zlib.h

    ├── lib

    │   ├── libz.a

    │   ├── libz.so -> libz.so.1.2.8

    │   ├── libz.so.1 -> libz.so.1.2.8

    │   ├── libz.so.1.2.8

    │   └── pkgconfig

    │       └── zlib.pc

    └── share

        └── man

            └── man3

                └── zlib.3

    3.  交叉编译dropbear。

    解压dropbear-2015.67.tar.bz2

    tar jvxf  dropbear-2015.67.tar.bz2

    cd dropbear-2015.67

    配置:

    ./configure --prefix=../../dropbear/install --with-zlib=../../zlib/install/ CC=arm-linux-gnueabihf-gcc --host=arm-linux

    会报如下错误:

    configure: error: expected an absolute directory name for --prefix: ../../dropbear/install

    因为—prefix需要一个绝对的路径,所以修该成如下进行配置

    ./configure --prefix=/home/vmuser/sdc/remote_svn/iotx-am335x/MC-183/package/dropbear/install --with-zlib=../../zlib/install/ CC=arm-linux-gnueabihf-gcc --host=arm-linux

    默认编译安装:

    default compile:

    make

    make install

     

    自定义编译安装:

    counster compile:

    make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"

    make PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install

     

    用tree 显示安装目录如下所示:

    install/

    ├── bin

    │   ├── dbclient

    │   ├── dropbearconvert

    │   ├── dropbearkey

    │   └── scp

    ├── sbin

    │   └── dropbear

    └── share

        └── man

            ├── man1

            │   ├── dbclient.1

            │   ├── dropbearconvert.1

            │   └── dropbearkey.1

            └── man8

                └── dropbear.8

    4.  测试:

    # download dbclient

    wget http://192.168.3.88/dropbear/install/bin/dbclient -O  /bin/dbclient   &&  chmod  +x  /bin/dbclient

    # download scp

    wget http://192.168.3.88/dropbear/install/bin/scp -O  /bin/scp   &&  chmod  +x  /bin/scp

    # download dropbearkey

    wget http://192.168.3.88/dropbear/install/bin/dropbearkey -O  /bin/dropbearkey   &&  chmod  +x  /bin/dropbearkey

    # download dropbearconvert

    wget http://192.168.3.88/dropbear/install/bin/dropbearconvert -O  /bin/dropbearconvert   &&  chmod  +x  /bin/dropbearconvert

    # download dropbear

    wget http://192.168.3.88/dropbear/install/sbin/dropbear -O  /bin/dropbear   &&  chmod  +x  /bin/dropbear

    # download libz so

    wget http://192.168.3.88/zlib/install/lib/libz.so.1.2.8 -O  /lib/libz.so.1.2.8 && chmod +x /lib/libz.so.1.2.8

    # create soft ln

    ln -s /lib/libz.so.1.2.8 /lib/libz.so

    ln -s /lib/libz.so.1.2.8 /lib/libz.so.1

    # mkdir /etc/dropbear

    mkdir -p /etc/dropbear

    cd  /etc/dropbear

    # generate dropbear_dss_host_key

    root@am335x:/etc/dropbear# dropbearkey -t dss -f dropbear_dss_host_key

    Generating key, this may take a while...

    Public key portion is:

    ssh-dss AAAAB3NzaC1kc3MAAACBAP3WPpjrRpLNaAZuABg4GYaHurc50gAmesgL/MFxj9aOfZ3n4GCmqD+fEfEkMok8KIdblyo7B/VX8ycM85EARMzQT7Y7t9KZRRIVTHNMG3NgalczaQOGYCdQs/QVNaMzKOCvt15rQQFdYNGmkoscNYROoKVau/16KJpC6QD70bAdAAAAFQDsjhDS8hI1Ilxo/t4UDl5q2VDnywAAAIEAjlslkIGvLQhxa1lm+3BL6PnXc9dIizfCMLtp+eS178fJdoLceLhC+FrTwVyaLAUrvElvqgkYkGtx/DtNmw3xyE2d6Fu4uFT1FuyPBJxxYAnJc6odKG64mZXSiPz5hkalcPmi/oDE4Y7TT6GwEorTQ5CyS7jZc/vgOOry5rG+gcUAAACBAP1Vvx4DsCVF0KEgx04j1sRzGp9MjkXd+S4sA1hOXUJ5VVmtqMYn5XBJTCfsNBCMsVAWAIP3usvHlLuXTD/nC23fUw2gPpBEBiCQCThbingyqT7wQ4ZQFlO8yHRr4peBxyUK2PFyVDPGohl5cSO+XaaWVUe33Cg/Rk5xl1Q4b5gbroot@am335x Fingerprint: md5 09:e2:6c:93:39:d0:08:1e:97:64:74:c8:d6:78:97:6e

    # generate dropbear_rsa_host_key

    root@am335x:/etc/dropbear# dropbearkey -t rsa -f dropbear_rsa_host_key

    Generating key, this may take a while...

    Public key portion is:

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5txR31wx+AXiy4nOanuocphD7VYTQa5L1yLmANQVZnZh2itRnuMrsAfSBOkKIOo2UwcK9iyJCWXFmcoLe6acXIeX/mAP4OzgOqi1gLJoBw/y3vmeIzJJP1Qn96iVhZqL1NLjqj863+LNi20WuvYzdKbd13dbTGnE7auDynKLlE+LudSg2MjDLhJ7VZ4tGagoxY4HkRfGgKha2+K7CeCvby29St5QOt8HWjbOBM6MaNqX09GH7W1hpzti39xpZwz8YakPWMgYd6/elBFtVx0tZhg/80xq1HHG5OtDM6Fzo+wtZODb5r2gEBvYPJ+DaX06x9f6WOaWXtKnV5IEu3GF/ root@am335x

    Fingerprint: md5 09:0c:bc:c0:c9:85:26:c1:aa:00:4a:0f:7e:23:33:1d

    # restart dropbear

    killall  -9 dropbear

    dropbear -p  22 &

  • 相关阅读:
    转载:网关的概念以及形象的比喻
    IP地址的分类
    Linux TOP 交互命令
    Unix系统引导过程(简单步骤)
    常用shell命令中你所不熟悉的参数
    3.通过现有的PDB创建一个新的PDB
    2.oracle 12c 创建-访问-关闭-删除PDB
    1.oracle 12c基础
    笔记本设置无线热点
    Pivot 和 Unpivot
  • 原文地址:https://www.cnblogs.com/lianghong881018/p/9576781.html
Copyright © 2011-2022 走看看