Hi3798 openSSH的移植

 

前言

在编译海思SDK时,会自动编译openssl,zlib,故无需重复编译这两者。

编译

编译openssh

本文下载openssh-7.3p1版本,将其下载至虚拟机

tar -xvf openssh-7.3p1.tar.gz
./configure --host=arm-linux --prefix=/usr/local/openssh --with-zlib=/hi3798/HiSTBLinuxV100R005C00SPC050/out/hi3798mv200/hi3798mv2dmo/obj/source/component/zlib/release --with-ssl-dir=/hi3798/HiSTBLinuxV100R005C00SPC050/out/hi3798mv200/hi3798mv2dmo/obj/source/component/openssl/release --disable-etc-default-login --disable-strip CC=arm-histbv320-linux-gcc AR=arm-histbv320-linux-ar

使前缀--prefix=/usr/local/openssh,因为最后openssh使安装在开发板的这个目录下,/hi3798/HiSTBLinuxV100R005C00SPC050/out/hi3798mv200/hi3798mv2dmo/obj/source/component/zlib/release是zlib在虚拟机下的安装目录,--with-ssl-dir=/hi3798/HiSTBLinuxV100R005C00SPC050/out/hi3798mv200/hi3798mv2dmo/obj/source/component/openssl/release 是ssl在虚拟机下的安装目录。

然后在openssh源目录下执行make

make

最终会在该目录下生成一下12个文件

scp sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan moduli ssh_config sshd_config sftp-server ssh-keysign

到目录下/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts目下解压rootfs.tar.bz2,得到rootfs文件夹,并且在rootfs文件夹下创建一下目录

/usr/local/openssh/bin
/usr/local/openssh/etc
/usr/local/libexec
/var/run
/var/empty

将以下文件拷贝到/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/usr/local/openssh/bin目录下:

在根文件系统的bin目录下建立软连接

ln -snf /usr/local/openssh/bin/scp
ln -snf /usr/local/openssh/bin/sftp
ln -snf /usr/local/openssh/bin/ssh
ln -snf /usr/local/openssh/bin/ssh-add
ln -snf /usr/local/openssh/bin/ssh-agent
ln -snf /usr/local/openssh/bin/ssh-keygen
ln -snf /usr/local/openssh/bin/ssh-keyscan
ln -snf /usr/local/openssh/bin/sshd

将moduli ssh_config sshd_config三个文件拷贝到/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/usr/local/openssh/etc目录下

并且执行以下命令生成证书密码对:

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 ""

至此,/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/usr/local/openssh/etc目录下有以下文件

将sshd_config中的PermitRootLogin no改为PermitRootLogin yes,将“Subsystem sftp /usr/libexec/sftp-server”改为“Subsystem    sftp    /usr/local/libexec/sftp-server”

将sftp-server  ssh-keysign拷贝至/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/usr/local/libexec

另外,在/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/etc/group中添加

sshd:x:1001:sshd

在/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/etc/gshadow中添加

sshd:!::sshd

在/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/etc/passwd中添加

sshd:x:1001:1001:sshd privsep:/var/empty:/bin/ssh

在/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/etc/shadow中添加

sshd:BsmGtKsu9a9a6:15506:5:99999:7:5:20000:

shadow文件的详细说明见http://c.biancheng.net/view/840.html

在/hi3798/HiSTBLinuxV100R005C00SPC050/source/rootfs/scripts/rootfs/autorun.sh中添加

#!/bin/sh

#addgroup sshd
#adduser -G sshd -g 'sshd privsep' -h /var/empty -p 123456 -s /bin/ssh sshd
#useradd -G sshd -g 'sshd privsep' -h /var/empty -p 123456 -s /bin/ssh sshd
echo root:123456 | chpasswd root

sed -i 's|:0:5:99999:7:5:20000:|:15506:5:99999:7:5:20000:|' /etc/shadow
chown -R root.root /var/empty
chmod 744 /var/empty
/usr/local/openssh/bin/sshd
echo "sleep 5"

在rcS末尾添加

cd /
chmod +x autorun.sh
./autorun.sh

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值