〖Linux〗build ssh for Arm

1. 交叉编译环境:

export ARCH=arm
export SUBARCH=arm
export PATH=/opt/FriendlyARM/toolschain/4.5.1/bin:$PATH
export CROSS_COMPILE=/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-

2. 安装依赖环境:

sudo aptitude install zlib1g-dev libssl-dev

3. 编译 zlib for ARM: 版本[zlib-1.2.8.tar.gz]

./configure --prefix=/opt/FriendlyARM/zlib
make -j4 -e \
"CC=arm-linux-gcc" \
"AR=arm-linux-ar" \
"CPP=arm-linux-gcc -E" \
"LDSHARED=arm-linux-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"
make install # 要求/opt目录的所有者为当前用户

4. 编译 openssl: 版本[openssl-1.0.1e.tar.gz]

unset CROSS_COMPILE #必须执行的命令!
./Configure --prefix=/opt/FriendlyARM/openssl os/compiler:arm-linux-gcc
make -j4
make install

5. 编译 openssh: openssh-6.3p1.tar.gz

./configure --prefix=/opt/FriendlyARM/openssh \
--host=arm-linux \
--with-zlib=/opt/FriendlyARM/zlib \
--with-ssl-dir=/opt/FriendlyARM/openssl \
CC=arm-linux-gcc
make -j4 # 不需要make install,安装不上的!!

 >>在PC打包ssh成为一个tar包:

#!/bin/sh -
tmpdir=tmp_arm
prefix=/opt/FriendlyARM/openssh
mkdir $tmpdir
mkdir -p $tmpdir/$prefix/etc
mkdir -p $tmpdir/$prefix/bin
mkdir -p $tmpdir/$prefix/etc
mkdir -p $tmpdir/$prefix/libexec
mkdir -p $tmpdir/$prefix/sbin
ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f ssh_host_dsa_key -N ""
ssh-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
cp ssh_host_*_key  $tmpdir/$prefix/etc/
cp scp  sftp  ssh  ssh-add  ssh-agent  ssh-keygen  ssh-keyscan $tmpdir/$prefix/bin/
cp moduli ssh_config sshd_config $tmpdir/$prefix/etc/
cp sftp-server  ssh-keysign $tmpdir/$prefix/libexec/
cp sshd $tmpdir/$prefix/sbin/
cd $tmpdir
tar zcf ssh_arm.tgz /opt/FriendlyARM/openssl /opt/FriendlyARM/zlib *

 >>把tar包拷贝至ARM板后,安装过程: 

#!/bin/sh -
# run on arm
tar zxf ssh_arm.tgz -C /
echo 'PATH=/opt/FriendlyARM/openssh/bin:/opt/FriendlyARM/openssh/sbin:$PATH' >> /etc/profile
echo 'sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin' >> /etc/passwd
source /etc/profile

  >> 效果展示:先在ARM板上执行 /opt/FriendlyARM/openssh/sbin/sshd

 

 这表明已经成功通过ssh连接至ARM开发板了。

 

参考资料:

  1. http://blog.sina.com.cn/s/blog_7f2a9a390100xws4.html

posted @ 2013-11-03 06:24  scue  阅读(1766)  评论(0编辑  收藏  举报