arm开发板移植sshd

移植sshd

文章目录

  • 移植sshd
    • 1、准备工作
    • 2、编译zlib
    • 3、编译openssl
    • 4、编译openssh
    • 5、其他旧版本
    • 6、部署测试
    • 7、多用户配置
    • 8、sshd_config示例

1、准备工作

准备openssh-9.5p1.tar.gz openssl-1.1.1w.tar.gz zlib-1.2.11.tar.gz

我在http://10.45.156.100/IG2100/IG2100.git IG2100/Build/source/third 找到如下源码库

-rw-rw-r-- 1 lanyx lanyx 1843001 530 13:59 openssh-9.5p1.tar.gz
-rw-rw-r-- 1 lanyx lanyx 9893384 530 13:59 openssl-1.1.1w.tar.gz
-rw-rw-r-- 1 lanyx lanyx  660294 530 13:59 zlib-1.2.11.tar.gz
//新建如下目录
lanyx@ubuntu:~/src_lib/sshd$ tree -L 2
.
├── build
├── out
│   ├── openssl
│   └── zlib
├── source
│   ├── openssh-9.5p1
│   ├── openssl-1.1.1w
│   └── zlib-1.2.11
└── tar├── openssh-9.5p1.tar.gz├── openssl-1.1.1w.tar.gz└── zlib-1.2.11.tar.gz

2、编译zlib

tar -zxvf zlib-1.2.11.tar.gz -C ../source/
cd ../source/zlib-1.2.11
./configure --prefix=/home/lanyx/src_lib/sshd/out/zlib
vim Makefile  //修改编译链
make
make install

在这里插入图片描述

3、编译openssl

tar -zxvf openssl-1.1.1w.tar.gz -C ../source/
cd ../source/openssl-1.1.1w/./Configure linux-generic32 no-asm no-threads no-zlib no-sse2 no-bf no-cast no-rc2 no-rc4 no-rc5 no-md2 no-mdc2 no-idea shared  --prefix=/home/lanyx/src_lib/sshd/out/openssl --cross-compile-prefix=arm-unknown-linux-gnu-
make 
make install

执行Configure的时候可能会报错:

hreads_pthread.c crypto/threads_pthread.c: In function `CRYPTO_THREAD_lock_new': crypto/threads_pthread.c:48: warning: implicit declaration of function `pthread_mutexattr_settype' crypto/threads_pthread.c:48: error: `PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function) crypto/threads_pthread.c:48: error: (Each undeclared identifier is reported only once crypto/threads_pthread.c:48: error: for each function it appears in.) make[1]: *** [Makefile:5103: crypto/threads_pthread.o] Error 1 make[1]: Leaving directory '/home/lanyx/src_lib/sshd/source/openssl-1.1.1w'处理:打开 crypto/threads_pthread.c 文件,添加以下定义#ifndef PTHREAD_MUTEX_RECURSIVE
#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
#endif

4、编译openssh

tar -zxvf openssh-9.5p1.tar.gz -C ../source/
cd ../source/openssh-9.5p
./configure --host=arm-linux --prefix=/home/lanyx/src_lib/sshd/out/openssh --with-zlib=/home/lanyx/src_lib/sshd/out/zlib --with-ssl-dir=/home/lanyx/src_lib/sshd/out/openssl --disable-etc-default-login CC=arm-unknown-linux-gnu-gcc AR=arm-unknown-linux-gnu-armake 
make install

5、其他旧版本

上述版本在在IG2000V3设备上可以运行,但是存在sshd无法启动sftp-server服务,导致ftp无法使用,因此又尝试了低版本。

//openssh7.6 && openssl1.0.2n
wget https://zlib.net/fossils/zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2n.tar.gz
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-7.6p1.tar.gz#zlib
./configure --prefix=/home/lanyx/src_lib/sshd-7.6/out/zlib
vim Makefile 
#修改编译链,一共有五处需要修改
make 
make install#openssl
./Configure linux-generic32 no-asm no-threads no-zlib no-sse2 no-bf no-cast no-rc2 no-rc4 no-rc5 no-md2 no-mdc2 no-idea shared  --prefix=/home/lanyx/src_lib/sshd-7.6/out/openssl --cross-compile-prefix=arm-unknown-linux-gnu-
make 
make install#openssh
#9g25
./configure --host=arm-linux --disable-strip --sysconfdir=/etc/ssh --prefix=/usr --with-zlib=/home/lanyx/src_lib/sshd-7.6/out/zlib --with-ssl-dir=/home/lanyx/src_lib/sshd-7.6/out/openssl  CC=arm-unknown-linux-gnu-gcc AR=arm-unknown-linux-gnu-ar #9x60
./configure --host=arm-linux --disable-strip --sysconfdir=/etc/ssh --prefix=/usr --with-zlib=/home/lanyx/src_lib/sshd-7.6/out/zlib --with-ssl-dir=/home/lanyx/src_lib/sshd-7.6/out/openssl  CC=arm-linux-gcc AR=arm-linux-ar --sysconfdir :代表ssdh_config配置文件的默认路径,我将此文件放在/etc/ssh/sshd_config,因此这里我写/etc/ssh--prefix    :代表相关的bin文件的前缀,这里我写的/usr,因为我的sftp-server放在/usr/libexec目录

上述版本测试后还是发现sshd无法正常启动sftp-server,但是在IG2100上可以启动,目前原因未知,

将sshd_config中的sftp修改为sshd内部的sftp,测试可以正常。

#Subsystem	sftp	/usr/libexec/sftp-server
Subsystem   sftp    internal-sftp`

小贴士:如果采用/usr/sbin/sshd -d这种方式启动,在IG2000V3上也是无法启动sftp的,一定要/usr/sbin/sshd&或者在启动文件中启动

6、部署测试

准备编译好的文件

-rw-r--r-- 1 lanyx lanyx  553185 6月   4 08:04 moduli
drwxrwxr-x 6 lanyx lanyx    4096 6月   3 18:41 openssl
-rwxrwxr-x 1 lanyx lanyx  212549 6月   4 08:03 scp
-rwxrwxr-x 1 lanyx lanyx  292247 6月   4 08:07 sftp
-rwxrwxr-x 1 lanyx lanyx  234073 6月   4 08:03 sftp-server
-rwxrwxr-x 1 lanyx lanyx 1447435 6月   4 08:03 ssh
-rwxrwxr-x 1 lanyx lanyx  706755 6月   4 08:04 ssh-add
-rwxrwxr-x 1 lanyx lanyx  754599 6月   4 08:04 ssh-agent
-rw-r--r-- 1 lanyx lanyx    1495 6月   4 08:04 ssh_config
-rwxrwxr-x 1 lanyx lanyx 1616635 6月   4 08:05 sshd
-rw-r--r-- 1 lanyx lanyx    3120 6月   4 16:29 sshd_config
-rwxrwxr-x 1 lanyx lanyx  863203 6月   4 08:03 ssh-keygen
-rwxrwxr-x 1 lanyx lanyx  916052 6月   4 08:03 ssh-keyscan
-rwxrwxr-x 1 lanyx lanyx  877530 6月   4 08:05 ssh-keysign
drwxrwxr-x 5 lanyx lanyx    4096 6月   3 18:35 zlib

确保设备有以下目录,如果没有则新建:

/usr//bin
/usr/libexec
/etc/ssh

将 openssh 目录下文件拷贝到开发板系统中,具体为:

客户端文件

scp、sftp、ssh 、ssh-add、ssh-agent、ssh-keygen、ssh-keyscan 共7个文件拷贝到开发板 /usr/bin

sshd配置文件

moduli、ssh_config、sshd_config 共3个文件拷贝到开发板 /etc/ssh

sftp-server文件

sftp-server、ssh-keysign 共2个文件拷贝到开发板 /usr/libexec
sshd 拷贝到 /usr/sbin
chmod 777 /usr/sbin/sshd
libz.so.1.2.11 拷贝到开发板 /lib (必须放在/lib下,不然scp会找不到这个库)
然后建立软链接:
ln -s libz.so.1.2.11 libz.so.1

将out/openssl/lib/libcrypto.so.1.0.0 也要复制到/lib

生成key文件:

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ""
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ""

将生成的 ssh_host_rsa_key 、 ssh_host_dsa_key 和 ssh_host_ecdsa_key 拷贝到 /etc/ssh
chmod 600 ssh_host_*
#如果开发板需要 ssh_host_key 的话,执行:
#ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N ""

如果出现 privilege separation user sshd 问题:
在 /etc/passwd 增加以下:

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

测试:

/usr/sbin/sshd -d

7、多用户配置

useradd ftptest -m -s /bin/sh -d /TELECOM #/TELECOM是用户目录
echo "ftptest:ftptest" | chpasswd         #修改密码
chmod 755 /TELECOM -R                     #修改权限,这里设置为755,只能下载不能上传,如果想要上传修改为766就可以

8、sshd_config示例

#	$OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key# Ciphers and keying
#RekeyLimit default nonekexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256# Logging
#SyslogFacility AUTH
#LogLevel INFO#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10PubkeyAuthentication yes# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile	.ssh/authorized_keys#AuthorizedPrincipalsFile none#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none# no default banner path
#Banner none# override default of no subsystems
#Subsystem	sftp	/usr/libexec/sftp-server
Subsystem   sftp    internal-sftp# Example of overriding settings on a per-user basis

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/23913.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

09.1手工制作docker镜像-多服务ssh+nginx

手工制作docker镜像-多服务sshnginx 一个容器多个服务 基于centos6.9系统添加yum源与epel源 安装nginx、ssh服务 yum install nginx openssh-server -y因镜像系统为纯系统,没有root密码,所以需要配置密码 echo 123456 | passwd --stdin root注&#x…

kafka-消费者组(SpringBoot整合Kafka)

文章目录 1、消费者组1.1、使用 efak 创建 主题 my_topic1 并建立6个分区并给每个分区建立3个副本1.2、创建生产者发送消息1.3、application.yml配置1.4、创建消费者监听器1.5、创建SpringBoot启动类1.6、屏蔽 kafka debug 日志 logback.xml1.7、引入spring-kafka依赖1.8、消费…

IT闲谈-WEB前端主流三大框架

目录 一、Angular二、React三、Vue.js小结 前言 这里给大家简单介绍一下web前端框架;随着互联网技术的飞速发展,Web前端技术也在不断地演进和更新。目前,前端比较多的三大主流前端框架Angular、React和Vue.js,成为前端开发者的得…

问题:棕色试剂瓶用于盛装见光易分解的试剂或溶剂。 #其他#学习方法#微信

问题:棕色试剂瓶用于盛装见光易分解的试剂或溶剂。 A、正确 B、错误 参考答案如图所示

响应式流规范解析

在互联网应用构建过程中,我们知道可以采用异步非阻塞的编程模型来提高服务的响应能力。而为了实现异步非阻塞,我们可以引入数据流,并对数据的流量进行控制。我们来考虑一个场景,如果数据消费的速度跟不上数据发出的速度&#xff0…

基于spring boot的超市管理系统【附:资料➕文档】

前言:我是源码分享交流Coding,专注JavaVue领域,专业提供程序设计开发、源码分享、 技术指导讲解、各类项目免费分享,定制和毕业设计服务! 免费获取方式--->>文章末尾处! 项目介绍: 网址 …

JWT及单点登录实现

JWT发展简史 JWT Token JSON Web Token (JWT,RFC 7519 (opens new window)),是为了在网络应用环境间传递声明而执行的一种基于 JSON 的开放标准((RFC 7519)。 ID Token OIDC (OpenID Connect) 协议 (opens new window)对 OAuth 2.0 协议 …

DEA统计代码行数插件Statistic

1.安装Statistic插件 直接在idea里面搜索Statistic即可 2.重启idea 3.查看代码行数 它可以统计各类文件的行数总和

【Linux】进程(7):地址空间

大家好,我是苏貝,本篇博客带大家了解Linux进程(7):地址空间,如果你觉得我写的还不错的话,可以给我一个赞👍吗,感谢❤️ 目录 (A) 直接看代码&…

法国人工智能初创公司 Mistral 正在推出新的人工智能模型定制选项服务和 SDK

Mistral AI是一家成立于2023年的法国人工智能初创公司,由Artur Mensch、Timothe Lacroix和Guillaume Lample三位前Meta和Google DeepMind的研究人员创立。该公司专注于生成式AI技术,特别是用于构建在线聊天机器人、搜索引擎等应用。 Mistral AI在成立之…

[数据集][图像分类]城市异常情况路边倒树火灾水灾交通事故分类数据集15223张8类别

数据集类型:图像分类用,不可用于目标检测无标注文件 数据集格式:仅仅包含jpg图片,每个类别文件夹下面存放着对应图片 图片数量(jpg文件个数):15223 分类类别数:8 类别名称:[“badroad”,“fallentree”,“f…

CarSim车辆运动轨迹绘制

CarSim车辆运动轨迹绘制 CarSim中与车辆位置有关的信息分别为Xo和Yo 输出到Simulink中 导入到工作空间中保存,low_carsim_path.mat ,绘制结果曲线,low_carsim_path_comp.m data csvread(low_two_path.csv,1,0); low_two_path_x data(:,1)…

分享我的新版FMEA培训心得

近日,我有幸参加了深圳天行健企业管理咨询公司举办的新版FMEA培训,这次学习不仅让我对FMEA有了更深入的理解,更使我在实际工作中找到了提升产品质量的新路径。 新版FMEA相较于传统版本,更加注重风险识别与预防,强调在…

【递归、搜索与回溯】递归算法

一、经验总结 递归 VS 迭代(循环) 递归和迭代都解决的是重复的子问题,因此两者是可以相互转化的。利用栈结构可以将递归算法转化为迭代算法。 递归和迭代各有其优缺点,选择时需根据具体场景和需求来决定。 递归的优点包括&#…

苹果眼镜(Vision Pro)专业咨询服务模式优化方案

一、精准定位: 专注于为Apple Vision Pro应用开发者提供一站式、全方位的专业咨询服务,致力于成为开发者在空间计算时代中不可或缺的合作伙伴,共同打造“下一个大事件”。 二、核心业务优化: visionOS策略咨询: 深入…

【氵】Archlinux+KDE Plasma+Wayland 安装nvidia驱动 / 开启HDR

参考: NVIDIA - Arch Linux 中文维基 (其实就是把 wiki 简化了一下 注:本教程适用 GeForce 930 起、10 系至 20 系、 Quadro / Tesla / Tegra K-系列以及更新的显卡(NV110 以及更新的显卡家族),此处以 RTX3060 为例 …

LlamIndex二 RAG应用开发

在AutoGen)系列后,我又开始了LlamIndex 系列。欢迎查询LlamaIndex 一 简单文档查询 - 掘金 (juejin.cn)了解LlamIndex,今天我们来看看LlamIndex的拿手戏,RAG应用开发。 何为RAG? RAG全称"Retrieval-Augmented Generation&q…

vue处理json数据

背景:后端返回的数据不是我想要的,现在需要把 name 替换为title(小声蛐蛐:又让我处理数据) 后端返回数据格式 修改字段操作:(使用递归遍历的方式将title属性赋了name的值) renderT…

详细分析Mysql临时变量的基本知识(附Demo)

目录 前言1. 用户变量2. 会话变量 前言 临时变量主要分为用户变量和会话变量 1. 用户变量 用户变量是特定于会话的,在单个会话内可以在多个语句中共享 以 符号开头在 SQL 语句中使用 SET 语句或直接在查询中赋值 声明和赋值 SET var_name value; -- 或者 SE…

构建Vue3项目的几种方式,如何简化setup写法

1、说明 在vue2版本中,我们使用vue-cli脚手架进行构建,而切换到Vue3之后,依然可以使用vue-cli脚手架进行构建,但是官方推荐使用vite工具进行构建,下面将介绍几种方式构建vue3项目。 2、使用vue-cli脚手架构建Vue3项目…