sshd移植

写在前面:单独移植openssh,只能实现开发板连接PC,而在PC需要登录开发板是不行的。sshd的运行需要openssl和zlib的库依赖。

交叉编译

在/home/ruby/work目下面创建ssh目录

# mkdir /work/lib            ----〉共享库目录,通过nfs挂载

# mkdir /work/ssh           -----〉工作目录

# cd  /work/ssh

# mkdir compressed install source  -----〉compressed 用于存放源码包

                                    Install    软件安装目录

                                    Source    源码包解压目录

#mv tarpakgs/openssh-5.1p1.tar.gz  /work/ssh/compressed

#mv tarpakgs/openssl-0.9.8e.tar.gz  /work/ssh/compressed

#mv tarpakgs/zlib-1.2.3.tar.tar        /work/ssh/compressed
*********交叉编译 zlib

# cd /home/ruby/work/ssh/compressed/

# tar xvf zlib-1.2.3.tar.tar  -C  ../source

# cd ../source/zlib-1.2.3

# ./configure --prefix=/work/ssh/install/zlib-1.2.3

# vim Makefile

CC=mipsel-linux-gcc

AR=mipsel-linux-ar rc

CPP =mipsel-linux-gcc -E

LDSHARED=mipsel-linux-gcc
然后 make
    make install
***********交叉编译openssl

# cd /work/ssh/compressed/

# tar zxvf openssl-0.9.8e.tar.gz  -C  ../source

# cd ../source/openssl-0.9.8e

./Configure --prefix=/home/ruby/work/ssh/install/openssl-0.9.8e os/compiler:mipsel-linux-gcc
然后make
   make install
***********交叉编译openssh

# cd /work/ssh/compressed

# tar zxvf openssh-4.6p1.tar.gz  –C ../source

# cd ../source/ openssh-4.6p1

./configure --host=mipsel-linux --with-libs --with-zlib=/home/ruby/work/ssh/install/zlib-1.2.3/ --with-ssl-dir=/home/ruby/work/ssh/install/openssl-0.9.8e --disable-etc-default-login CC=mipsel-linux-gcc AR=mipsel-linux-ar

执行完毕后,会打印出以下信息:

OpenSSH has been configured with the following options:
                     User binaries: /usr/local/bin
                   System binaries: /usr/local/sbin
               Configuration files: /usr/local/etc
                   Askpass program: /usr/local/libexec/ssh-askpass
                      Manual pages: /usr/local/share/man/manX
                          PID file: /var/run
  Privilege separation chroot path: /var/empty
  sshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
                    Manpage format: doc
                       PAM support: no
                   OSF SIA support: no
                 KerberosV support: no
                   SELinux support: no
                 Smartcard support: no
                     S/KEY support: no
              TCP Wrappers support: no
              MD5 password support: no
                   libedit support: no
  Solaris process contract support: no
       IP address in $DISPLAY hack: no
           Translate v4 in v6 hack: yes
                  BSD Auth support: no
              Random number source: OpenSSL internal ONLY

    Host: mipsel-unknown-linux-gnu
    Compiler: mipsel-linux-gcc
    Compiler flags: -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -fno-builtin-memset -std=gnu99
Preprocessor flags: -I/home/ruby/work/ssh/install/openssl-0.9.8e/include -I/home/ruby/work/ssh/install/zlib-1.2.3//include
      Linker flags: -L/home/ruby/work/ssh/install/openssl-0.9.8e/lib -L/home/ruby/work/ssh/install/zlib-1.2.3//lib
      Libraries: -lresolv -lcrypto -lutil -lz -lnsl  -lcrypt

然后 make  不要make install

然后mipsel-linux-strip -s sshd    这个操作可以将sshd变小。
#把sshd复制到目标板的根文件系统的/usr/sbin
#cp sshd /nfsroot/rootfs/usr/sbin

建立密钥:
ssh-keygen -t rsa1 -f ssh_host_key -N ""
ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f ssh_host_dsa_key -N ""

建立文件夹/usr/local/etc/。然后把openssh目录下的sshd_config拷贝到该文件夹下面

cp scp  sftp  ssh  ssh-add  ssh-agent  ssh-keygen  ssh-keyscan /nfsroot/rootfs/usr/local/bin
cp moduli  ssh_config  sshd_config  ssh_host_dsa_key  ssh_host_dsa_key.pub  ssh_host_key  ssh_host_key.pub  ssh_host_rsa_key  ssh_host_rsa_key.pub  /nfsroot/rootfs/usr/local/etc

# cp sftp-server  ssh-keysign   /nfsroot/rootfs/usr/local/libexec

# cp sshd   /nfsroot/rootfs/usr/local/sbin

·建立目录/var/run /var/empty/sshd,并设定权限chmod 755 /var/empty

修改  /usr/local/etc    sshd_config文件如下选项:

PermitRootLogin    yes―――――允许根用户登陆

PermitEmptyPasswords yes――――允许使用空密码

UsePrivilegeSeparation   no――――把安全级别降低,因为不会连接互联网

好了 ,现在可以运行  /usr/local/sbin/sshd
在PC可以连接开发板了
ssh root@192.168.4.128
done!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值