海思3516 openssh交叉编译

海思3516 openssh交叉编译

编译

wget https://mirrors.aliyun.com/openssh/portable/openssh-6.2p1.tar.gz
wget https://udomain.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1t.tar.gz

export OPENSSH_NAME="openssh-6.2p1"
export ZLIB_NAME="zlib-1.2.8"
export OPENSSL_NAME="openssl-1.0.1t"

tar -xzf $OPENSSH_NAME.tar.gz
tar -xzf $ZLIB_NAME.tar.gz
tar -xzf $OPENSSL_NAME.tar.gz

cd  $ZLIB_NAME
mkdir _install
./configure --prefix=$PWD/_install/ 
# 修改Makefile,指定交叉编译链,在原来的基础上改,不要删除多余的东西
# vi Makefile
CC=arm-himix200-linux-gcc
AR=arm-himix200-linux-ar
CPP =arm-himix200-linux-gcc -E
LDSHARED=arm-himix200-linux-gcc

make&&make install

cd ../$OPENSSL_NAME
mkdir _install
./Configure --prefix=$PWD/_install os/compiler:arm-himix200-linux-gcc
make&&make install

cd ../$OPENSSH_NAME

# 这里的前缀是在板子上的,配置文件路径
./configure --host=arm-himix200-linux --prefix=/usr/local/openssh --with-zlib=$PWD/../$ZLIB_NAME/_install --with-ssl-dir=$PWD/../$OPENSSL_NAME/_install --disable-etc-default-login --disable-strip CC=arm-himix200-linux-gcc AR=arm-himix200-linux-ar LDFLAGS="-static -pthread" 
make

打包文件

cd ../$OPENSSH_NAME
mkdir -p final/usr/local/openssh/etc/
mkdir -p final/usr/local/openssh/bin/
mkdir -p final/usr/local/libexec
mkdir -p final/bin
mkdir -p final/sbin

cp scp sftp ssh  ssh-add ssh-agent  ssh-keygen ssh-keyscan ./final/usr/local/openssh/bin
cp sshd_config ssh_config ./final/usr/local/openssh/etc 
cp sshd ./final/sbin
cp sftp-server  ssh-keysign ./final/usr/local/libexec
cd ./final
tar czvf openssh.tgz ./ 

板端配置

# 没空间了,只能放TF卡上了
export SSH_PATH="/mnt/TF/ssh"
export PATH="$PATH:$SSH_PATH/usr/local/openssh/bin:$SSH_PATH/sbin"
export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:$SSH_PATH/usr/local/openssh/lib-exec'
# 建个软连接,不关心具体的路径
ln -s  /mnt/TF/ssh/usr/local/ /usr/local/
ln -s  /mnt/TF/ssh/sbin/sshd /usr/sbin/sshd

# passwd
echo "sshd::15:50:::/bin/sh" >> /etc/passwd
# group
echo "sshd:*:50:" >> /etc/group

mkdir -p /var/run/sshd
mkdir -p /var/empty

# TF格式需要ext4
# 路径可以在配置文件里修改
cd /usr/local/openssh/etc/
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-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
chmod -Rc 600 ssh_host_*

/usr/sbin/sshd

海思3516 openssh交叉编译_第1张图片

参考

  1. HI3516DV300笔记(三)安装SSH和SFTP

你可能感兴趣的:(海思学习笔记,linux,ssh,服务器)