〖Linux〗build ssh for Arm

1. 交叉編譯環境:html

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. 安裝依賴環境:linux

sudo aptitude install zlib1g-dev libssl-dev

3. 編譯 zlib for ARM: 版本[zlib-1.2.8.tar.gz]ssh

./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]spa

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

5. 編譯 openssh: openssh-6.3p1.tar.gzcode

./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包:server

#!/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板後,安裝過程: htm

#!/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/sshdblog

 

 這代表已經成功經過ssh鏈接至ARM開發板了。ip

 

參考資料:ssl

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

相關文章
相關標籤/搜索