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,一经查实,立即删除!

相关文章

git-daemon命令开启git服务器

文章目录 git daemon命令开启git服务器,供局域网其他电脑拉取、上传代码1. 创建文件夹,用于存放repository2. 把git代码文件夹放到创建的文件夹中3. 启动git带的服务,开启仓库4. 局域网中其他电脑设置仓库地址 git daemon命令开启git服务器&a…

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、消费…

HTML5拖放(Drag and Drop)全面指南:让网页互动起来

HTML5 引入了许多令人兴奋的新特性,其中之一便是原生支持的拖放(Drag and Drop)功能,它极大地丰富了网页的交互体验,允许用户直接在页面上通过鼠标操作来移动元素。本文将深入浅出地介绍如何在你的网页中实现拖放功能&…

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.查看代码行数 它可以统计各类文件的行数总和

Mysql基础进阶速成版

一:sql语句: 1.创建一张表:写成公式:创建函数(create table)表名(配置字段)。配置字段公式:字段名称字段类型,常用的类型有:整数类型int(8),int(16),int(32).....,小数类型float(8),float(16).…

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

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

go语言接口之sort.Interface接口

排序操作和字符串格式化一样是很多程序经常使用的操作。尽管一个最短的快排程序只要15 行就可以搞定,但是一个健壮的实现需要更多的代码,并且我们不希望每次我们需要的时候 都重写或者拷贝这些代码。 幸运的是,sort包内置的提供了根据一些排序…

PostgreSQL和MySQL架构模型的区别

PostgreSQL - 多进程架构 PostgreSQL采用了一种多进程架构。在这种模型下,每个数据库连接被分配给一个新的服务器进程(或者说是数据库进程)。这种方式为每个连接提供了独立的内存空间和执行环境。这样做的优点是提高了系统的稳定性和隔离性&…

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

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

python之List记录

1. 列表(List)基础 Python中的列表是一种可变、有序的元素集合,元素之间通过逗号分隔并包含在一对方括号内。列表的元素可以是不同类型的数据。 创建列表 # 创建一个包含不同类型元素的列表 my_list [1, 2.5, hello, True, [1, 2, 3]]访问…

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

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

Android-Q升级-Camera记录

目录 代码环境 建立Android Q使用的camera仓 Camera底层适配 camx 原生接口变化 其他编译问题 chi-cdk 数据类型不匹配 case未加break的报错 libalRnBRT_GL_GBWRAPPER链接问题 vidhance编译错误 libarcsat链接问题 vendor/qcom/proprietary prebuilt_HY11 调试cam…

floor函数

添加链接描述\ #include<bits/stdc.h>using namespace std;const int N 10;int main() {int n;cin>>n;for(int i1;i<50000;i){if(floor(i*1.08)n){cout<<i;return 0;}}cout<<":(";return 0; }floor函数是向下取整 ceil是向上取整 round…

CarSim车辆运动轨迹绘制

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