分享

移植ssh到arm

 mrjbydd 2013-08-06
1. 下载需要的源码:
    mkdir -p ~/arm/fs ;mkdir -p ~/arm/source
    下载zlib: wget -c http://www./zlib-1.2.3.tar.gz
    下载ssl: wget -c http://www./source/openssl-0.9.8d.tar.gz
    下载ssh: wget -c http://mirror.mcs./openssh/portable/openssh-4.6p1.tar.gz


2. 编译:
    cd ~/arm/source

    (1) 编译zlib:
     tar zxvf zlib-1.2.3.tar.gz -C .
     cd zlib-1.2.3/
     ./configure --prefix=/home/david/fs/zlib-1.2.3
    修改Makefile:
       CC=gcc 改为:
       CROSS=arm-linux-
   CC=$(CROSS)gcc
       LDSHARED=gcc 改为: LDSHARED=$(CROSS)gcc
       CPP=gcc -E   改为: CPP=$(CROSS)gcc -E
       AR=ar rc     改为: AR=$(CROSS)ar rc
开始编译: make;
           make install

   (2) 编译openssl:
       tar zxvf openssl-0.9.8d.tar.gz
    ./Configure --prefix=/home/david/fs/openssl-0.9.8d os/compiler:arm-linux-gcc
    make
    make install

   (3) 编译openssh:
    tar zxvf openssh-4.6p1.tar.gz
    cd openssh-4.6p1/
    ./configure --host=arm-linux --with-libs --with-zlib=/home/linksens/tools/fs/zlib-1.2.3
         --with-ssl-dir=/home/david/fs/openssl-0.9.8d --disable-etc-default-login    
         CC=arm-linux-gcc AR=arm-linux-ar
      make
    ##不要make install


3. 安装
    
    (1) 将 openssh-4.6p1目录下的 sshd 拷贝到 目标板的/usr/sbin目录下
    (2) 再copy scp   sftp  ssh   ssh-add   ssh-agent   ssh-keygen   ssh-keyscan 到目标板/usr/local/bin目录下
          copy 
sftp-server   ssh-keysign    到/usr/local/libexec
       
    (3) 在目标板下:

        mkdir -p /usr/local/etc/ 
        然后将openssh下的sshd_config,ssh_config 拷贝到该目录下

        mkdir -p /var/run; mkdir -p /var/empty/sshd 
        chmod 755 /var/empty     
    (4)在主机上:
                  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 ""
        将生存的 ssh_host_* 4个文件copy到目标板的 /usr/local/etc/目录下
     (5) 添加用户:
    将主机上 /etc/目下的 passwd, shadow, group 三个文件copy到目标板的 /etc目录下, 同时记得将passwd的最后 /bin/bash 该为 /bin/sh 
    其实可以删除不需要的一些用户。
     
4.测试
   目标板启动sshd: # /usr/sbin/sshd
     主机: $ ssh root@192.168.237.239

ps: 红色的那些代表让arm做ssh server时必须的

以上参考:http://hi.baidu.com/fcni_cn/blog/item/4a3ee7115e08cd18b8127b4f.html


遇到问题:
1 Permissions 0644 for '/usr/local/etc/ssh_host_key' are too open
此为文件的权限问题,解决方法为:

# cd /usr/local/etc

# ls

moduli ssh_host_dsa_key ssh_host_key ssh_host_rsa_key sshd_config

ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub

# ls -l

total 194

-rwxr-xr-x 1 bin bin 88039 Nov 21 2002 moduli

-rwxr-xr-x 1 bin bin 1144 Nov 21 2002 ssh_config

-rwxr-xr-x 1 root other 672 Dec 19 13:55 ssh_host_dsa_key

-rwxr-xr-x 1 root other 600 Dec 19 13:55 ssh_host_dsa_key.pub

-rwxr-xr-x 1 root other 525 Dec 19 13:54 ssh_host_key

-rwxr-xr-x 1 root other 329 Dec 19 13:54 ssh_host_key.pub

-rwxr-xr-x 1 root other 887 Dec 19 13:55 ssh_host_rsa_key

-rwxr-xr-x 1 root other 220 Dec 19 13:55 ssh_host_rsa_key.pub

-rwxr-xr-x 1 bin bin 2470 Nov 21 2002 sshd_config

# chmod 0644 *

# ls -l

total 194

-rw-r--r-- 1 bin bin 88039 Nov 21 2002 moduli

-rw-r--r-- 1 bin bin 1144 Nov 21 2002 ssh_config

-rw-r--r-- 1 root other 672 Dec 19 13:55 ssh_host_dsa_key

-rw-r--r-- 1 root other 600 Dec 19 13:55 ssh_host_dsa_key.pub

-rw-r--r-- 1 root other 525 Dec 19 13:54 ssh_host_key

-rw-r--r-- 1 root other 329 Dec 19 13:54 ssh_host_key.pub

-rw-r--r-- 1 root other 887 Dec 19 13:55 ssh_host_rsa_key

-rw-r--r-- 1 root other 220 Dec 19 13:55 ssh_host_rsa_key.pub

-rw-r--r-- 1 bin bin 2470 Nov 21 2002 sshd_config

# chmod 0600 ssh_host_dsa_key ssh_host_key ssh_host_rsa_key

# ls -l

total 194

-rw-r--r-- 1 bin bin 88039 Nov 21 2002 moduli

-rw-r--r-- 1 bin bin 1144 Nov 21 2002 ssh_config

-rw------- 1 root other 672 Dec 19 13:55 ssh_host_dsa_key

-rw-r--r-- 1 root other 600 Dec 19 13:55 ssh_host_dsa_key.pub

-rw------- 1 root other 525 Dec 19 13:54 ssh_host_key

-rw-r--r-- 1 root other 329 Dec 19 13:54 ssh_host_key.pub

-rw------- 1 root other 887 Dec 19 13:55 ssh_host_rsa_key

-rw-r--r-- 1 root other 220 Dec 19 13:55 ssh_host_rsa_key.pub

-rw-r--r-- 1 bin bin 2470 Nov 21 2002 sshd_config

2 在ssh目标机时出现

ssh root@192.168.237.239

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

97:ff:ec:78:48:69:c0:61:1d:82:9b:6c:2e:6b:6b:46.

Please contact your system administrator.

Add correct host key in /root/.ssh/known_hosts to get rid of this message.

Offending key in /root/.ssh/known_hosts:11

RSA host key for 192.168.237.239 has changed and you have requested strict checking.

Host key verification failed.

警告中已经说

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多