已经在zynq,hi3519, hi3559,SD3403等多类型芯片上运用
下载所需资源 zlib、openssl、openssh、haveged
本人下载的版本
进行解压
tar -zxvf openssl-3.1.2.tar.gz
tar -zxvf openssh-9.4p1.tar.gz
tar -zxvf haveged-1.9.2.tar.gz
然后 创建编译之后的安装文件夹,注意,openssh不需要创建
得到
在hi3519中,需要使用低版本的openssl和openssh,其他可以保持不变,版本使用版本如下图
开始进行配置,编译。
编译zlib
进入zlib源码路径
配置 ./configure --prefix=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/zlib-v1.2.12_install
需要注意,设置合适自己的路径和交叉编译工具链
修改makefile
执行 make; make install
之后就生成了所需的zlib库
编译openssl
进入openssl源码路径
配置
./config no-asm shared no-async --prefix=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/openssl-3.1.2_install --cross-compile-prefix=aarch64-mix210-linux-
需要注意,设置合适自己的路径和交叉编译工具链
执行 make
出现错误, 尝试修改makefile,去除 -m64
执行 make install
之后就生成了所需的openssl库
注意有多种方式,如果出现问题,可以使用下面的方式
./Configure --prefix=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/openssl-3.1.2_install os/compiler:aarch64-mix210-linux-gcc
编译openssh
进入openssh源码路径
配置
./configure --host=aarch64-mix210-linux --with-zlib=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/zlib-v1.2.12_install --with-ssl-dir=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/openssl-3.1.2_install CC=aarch64-mix210-linux-gcc AR=aarch64-mix210-linux-ar
需要注意,设置合适自己的路径和交叉编译工具链
编译 make
生成所需要的openssh库和程序
创建sshd的程序和库路径
mkdir -p usr/local/bin/ usr/local/sbin/ usr/local/etc/ usr/local/libexec/ var var/run/ var/empty/
cp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan usr/local/bin/
cp ssh_config sshd_config usr/local/etc/
cp sftp-server ssh-keysign usr/local/libexec/
cp sshd usr/local/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 “”
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N “”
修改权限
chmod 600 ssh_host_*_key
cp ssh_host_*_key usr/local/etc
修改usr/local/etc/sshd_config文件
密钥文件配置
允许root用户登录
空密码登录
sftp应用配置
编译haveged
进入haveged源码路径
配置
./configure --host=aarch64-mix210-linux --prefix=/fileDisk/SD3403/SS928V100_SDK_V2.0.2.1/osdrv/pub/ssh/haveged-1.9.2_install
需要注意,设置合适自己的路径和交叉编译工具链
编译 make;make install
生成所需要的haveged库和程序
配置程序到arm板卡上
首先将openssh中的usr、var文件夹复制到要制作的文件系统中
复制相关的zlib动态库,openssl库,haveged库到要制作的文件系统中
复制 haveged 程序到文件系统中的 /bin 目录下
修改文件系统中 /etc/init.d/rcS文件,增加以下内容
#start haveged
haveged -F -d 32 -w 1024 --verbose=1 &
#config ssh
chown -R root.root /var/empty
chmod 744 /var/empty
/usr/local/sbin/sshd -f /usr/local/etc/sshd_config &
在 /etc/passwd 增加内容
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
接下来可以制作文件系统,进行烧写测试ssh和sftp
enjoy
使用脚本
编译opencvssh
1.编译zlib
./configure --prefix=/filesDisk/hi3559AV100/Hi3559AV100_SDK_V2.0.2.0/osdrv/pub/ssh/zlib-v1.2.12_install
修改makefile
aarch64-himix100-linux-
make -j4
make install
cd ssh/zlib-v1.2.12_install/lib/
cp libz.so.1.2.12 …/…/…/rootfs_glibc_multi-core_arm64/lib64/
cd …/…/…/rootfs_glibc_multi-core_arm64/lib64/
ln -s libz.so.1.2.12 libz.so.1.2
ln -s libz.so.1.2.12 libz.so.1
ln -s libz.so.1.2.12 libz.so
2.编译openssl
./config no-asm shared no-async --prefix=/filesDisk/hi3559AV100/Hi3559AV100_SDK_V2.0.2.0/osdrv/pub/ssh/openssl-3.1.2_install --cross-compile-prefix=aarch64-himix100-linux-
修改makefile中,去除 -m64
make -j4
make install
cd ssh/openssl-3.1.2_install/lib64/
cp libcrypto.so.3 libssl.so.3 …/…/…/rootfs_glibc_multi-core_arm64/lib64/
cd …/…/…/rootfs_glibc_multi-core_arm64/lib64
ln -s libssl.so.3 libssl.so
ln -s libcrypto.so.3 libcrypto.so
3.编译openssh
./configure --host=aarch64-mix210-linux --with-zlib=/filesDisk/hi3559AV100/Hi3559AV100_SDK_V2.0.2.0/osdrv/pub/ssh/zlib-v1.2.12_install --with-ssl-dir=/filesDisk/hi3559AV100/Hi3559AV100_SDK_V2.0.2.0/osdrv/pub/ssh/openssl-3.1.2_install CC=aarch64-himix100-linux-gcc AR=aarch64-himix100-linux-ar
make -j4
配置
mkdir -p usr/local/bin/ usr/local/sbin/ usr/local/etc/ usr/local/libexec/ var var/run/ var/empty/
cp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan usr/local/bin/
cp ssh_config sshd_config usr/local/etc/
cp sftp-server ssh-keysign usr/local/libexec/
cp sshd usr/local/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 “”
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N “”
cp ssh_host_*_key usr/local/etc
修改usr/local/etc/sshd_config
复制 usr 和 var 文件夹到 文件系统路径下
4.编译haveged
./configure --host=aarch64-himix100-linux --prefix=/filesDisk/hi3559AV100/Hi3559AV100_SDK_V2.0.2.0/osdrv/pub/ssh/haveged-1.9.2_install
make -j4
make install
复制 haveged-1.9.2_install/sbin/haveged 到 文件系统路径下sbin文件夹下
sudo cp sbin/haveged …/…/rootfs_glibc_multi-core_arm64/sbin/
sudo cp lib/libhavege.so.1.1.0 …/…/rootfs_glibc_multi-core_arm64/lib64/
创建链接
cd …/…/rootfs_glibc_multi-core_arm64/lib64
ln -s libhavege.so.1.1.0 libhavege.so.1.1
ln -s libhavege.so.1.1.0 libhavege.so.1
ln -s libhavege.so.1.1.0 libhavege.so
修改/etc/passwd
增加
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
登录账号root
密码为空