移植openssh

2023-11-01 147浏览
百检网是一家专业的第三方检测平台,汇聚众多拥有权威资质的第三方检测机构为你提供一站式的检测服务,做检测就上百检网。百检网让检测从此检测,一份报告全国通用,专业值得信赖。

一、环境介绍

1.1 宿主机

Ubuntu 1404 32 位

1.2 嵌入式平台

ATMEL AT91SAM9X25

1.3 交叉工具链

arm-none-linux-gnueabi

openssh-7.5-p1移植所需源码包下载地址

二、交叉编译

2.1 先编译 openssh-7.5-p1 依赖的模块

2.1.1 zlib

tar xvf zlib-1.2.11.tar.xz

cd zlib-1.2.11/

export CC=arm-none-linux-gnueabi-gcc

./configure --prefix=$PWD/tmp

make CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar LD=arm-none-linux-gnueabi-ld ANLIB=arm-none-linux-gnueabi-ranlib

make install

2.1.2 openssl

tar xvf openssl-1.0.2o.tar.gz

cd openssl-1.0.2o/

./Configure --prefix=$PWD/tmp os/compiler:arm-none-linux-gnueabi-gcc

make

make install

2.2 openssh

不执行 make install, 因为安装是在当前系统部署

bash

tar xvf openssh-7.5p1.tar.gz

cd openssh-7.5p1/

./configure --host=arm-none-linux-gnueabi --build=i686-linux --prefix=$PWD/tmp --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc/ssh --libexecdir=/usr/libexec --with-privsep-user=sshd --with-privsep-path=/var/empty -with-libs --with-zlib=/home/gino/work/jiaxian/9X25/transplant/openssh-node/zlib-1.2.11/tmp --with-ssl-dir=/home/gino/work/jiaxian/9X25/transplant/openssh-node/openssl-1.0.2o/tmp --disable-etc-default-login CC=arm-none-linux-gnueabi-gcc AR=arm-none-linux-gnueabi-ar --disable-lastlog --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx

make

三、部署

3.1 ssh 运行依赖的设备文件

/dev/tty

/dev/random

/dev/urandom

3.2 文件及目录

/var/empty

~ # ls -l /etc/ssh

-rw-r--r-- 1 root root 1642 May 21 2018 ssh_config

-rw----r-- 1 root root 668 May 21 2018 ssh_host_dsa_key

-rw-r--r-- 1 root root 598 May 21 2018 ssh_host_dsa_key.pub

-rw----r-- 1 root root 227 May 21 2018 ssh_host_ecdsa_key

-rw-r--r-- 1 root root 170 May 21 2018 ssh_host_ecdsa_key.pub

-rw----r-- 1 root root 399 May 21 2018 ssh_host_ed25519_key

-rw-r--r-- 1 root root 90 May 21 2018 ssh_host_ed25519_key.pub

-rw----r-- 1 root root 1675 May 21 2018 ssh_host_rsa_key

-rw-r--r-- 1 root root 390 May 21 2018 ssh_host_rsa_key.pub

-rw-r--r-- 1 root root 3156 May 21 2018 sshd_config

/usr/bin/scp

/usr/bin/sftp

/usr/bin/ssh

/usr/bin/ssh-add

/usr/bin/ssh-agent

/usr/bin/ssh-keygen

/usr/bin/ssh-keyscan

/usr/sbin/sshd

/usr/libexec/sftp-server

/usr/libexec/ssh-keysign

**note:**key 文件的生成是在目标板执行以下命令,另外需要注意的是 key 文件的权限

cd /etc/ssh/

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

ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N ""

3.3 其它需要修改的文件

/etc/passwd 新增

sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin

/etc/ssh/sshd_config 修改

PermitRootLogin yes


百检网秉承“客户至上,服务为先,精诚合作,以人为本”的经营理念,始终站在用户的角度解决问题,为客户提供“一站购物式”的新奇检测体验,打开网站,像挑选商品一样简单,方便。打破行业信息壁垒,建构消费和检测机构之间高效的沟通平台