arm开发板移植sshd

news2024/9/21 20:35:35

移植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-ar

make 
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 none

kexalgorithms 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 10

PubkeyAuthentication 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.coloradmin.cn/o/1808335.html

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

相关文章

栈的实现和括号匹配问题

1.什么是栈 栈:一种特殊的线性表,其只允许在固定的一端进行插入和删除元素操作。进行数据插入和删除操作的一端 称为栈顶,另一端称为栈底。栈中的数据元素遵守后进先出LIFO(Last In First Out)的原则。 压栈&#xf…

数据中心智能化运维发展研究报告(2023)解读

数据中心智能化运维发展研究报告(2023)解读 《数据中心智能化运维发展研究报告(2023)》探讨了数据中心智能化运维的概念、核心内容、实际应用和发展建议。报告指出,通过人工智能、大数据等新一代信息技术的深度应用&a…

【recast-navigation-js】使用three.js辅助绘制Agent寻路路径

目录 说在前面setAgentTarget绘制寻路路径结果问题其他 说在前面 操作系统:windows 11浏览器:edge版本 124.0.2478.97recast-navigation-js版本:0.29.0golang版本:1.21.5上一篇:【recast-navigation-js】使用three.js辅…

STM32CubeIDE使用过程记录

最近在做一款机器人的开发,使用到了STM32CubeIDE,这里记录一些使用技巧方便后续查阅。 STM32CubeIDE使用过程记录 快捷键开启代码自动补全功能看门狗设置CRC设置IO口取反定时器设置 及 定时器中断外部中断GPIO配置STC15单片机GPIO模式配置片内闪存&#…

PyTorch学习7:加载数据集

文章目录 前言一、epoch,batch-size和iteration二、示例1.说明2.代码示例 总结 前言 介绍PyTorch中加载数据集的相关操作。Dataset和DataLoader 一、epoch,batch-size和iteration epoch:所有训练数据完成一次前馈和反馈 batch-size&#x…

深度学习革命-AI发展详解

深度学习革命 《深度学习革命》是一部引人深思的作品,详细讲述了深度学习技术的发展历程及其对各个行业的深远影响。由杰出的计算机科学家、深度学习专家撰写,这本书不仅适合科技领域的专业人士阅读,也为普通读者提供了一个理解人工智能革命…

Vue TypeScript 实战:掌握静态类型编程

title: Vue TypeScript 实战:掌握静态类型编程 date: 2024/6/10 updated: 2024/6/10 excerpt: 这篇文章介绍了如何在TypeScript环境下为Vue.js应用搭建项目结构,包括初始化配置、创建Vue组件、实现状态管理利用Vuex、配置路由以及性能优化的方法&#x…

【电机控制】FOC算法验证步骤——电流环PI参数、速度环PI参数

【电机控制】FOC算法验证步骤——电流环PI参数、速度环PI参数 文章目录 前言一、电流环PI1.TI手册 二、速度环PI1.TI手册——根据稳定性和带宽计算速度环PI参数2.TI手册——根据稳定性和带宽计算速度环PI参数 三、参考文献总结 前言 【电机控制】直流有刷电机、无刷电机汇总—…

Python私教张大鹏 Vue3整合Vue Router之编程式导航

除了使用 <router-link> 创建 a 标签来定义导航链接&#xff0c;我们还可以借助 router 的实例方法&#xff0c;通过编写代码来实现。 导航到不同的位置 注意: 下面的示例中的 router 指代路由器实例。在组件内部&#xff0c;你可以使用 $router 属性访问路由&#xff…

vue-cli是什么?和 webpack是什么关系?

前言 Vue CLI是Vue.js项目的官方脚手架&#xff0c;基于Node.js与Webpack构建。安装Vue CLI前需确保Node.js已安装&#xff0c;随后通过npm全局安装。Vue CLI能迅速创建和管理Vue.js项目&#xff0c;提升开发效率。而Webpack则负责资源打包&#xff0c;通过配置文件管理依赖、插…

FiRa标准UWB MAC实现(三)——距离如何获得?

继续前期FiRa MAC相关介绍,将FiRa UWB MAC层相关细节进一步进行剖析,介绍了UWB技术中最重要的一个点,高精度的距离是怎么获得的,具体使用的测距方法都有哪些,原理又是什么。为后续FiRa UWB MAC的实现进行铺垫。 3、测距方法 3.1 SS-TWR SS-TWR为Single-Sided Two-Way Ra…

通过python操作redis(windows)

注意在连接之前要确保 redis 服务已经安装。 更多的安装信息请查看&#xff1a;https://blog.csdn.net/sinat_20471177/article/details/132042779?spm1001.2014.3001.5501 redis 模块 Python 要使用 redis&#xff0c;需要先安装 redis 模块。如果要做数据导入/导出操作的…

动手学深度学习4.10 实战Kaggle比赛:预测房价-笔记练习(PyTorch)

以下内容为结合李沐老师的课程和教材补充的学习笔记&#xff0c;以及对课后练习的一些思考&#xff0c;自留回顾&#xff0c;也供同学之人交流参考。 本节课程地址&#xff1a;实战 Kaggle 比赛&#xff1a;预测房价_哔哩哔哩_bilibili 本节教材地址&#xff1a;4.10. 实战Ka…

公式转换坑

在线LaTeX公式编辑器-编辑器 (latexlive.com) 这个好用 latex输入后转mathtype等 1 \mathcal{V}\{0,1,\ldots,|\mathcal{V}|-1\} 这个玩意在Word死活打不出来 使用下面的方法也不行 mathtype也不行 故换符号之 LaTeX公式与MathType公式如何快速转换-MathType中文网 如何在…

.Net实现SCrypt Hash加密

方案1 &#xff08;加密后存储“算法设置”、“盐(随机值)”、“Hash值”&#xff0c;以“$”分隔&#xff09;&#xff1a; //Nuget引入SCrypt.NET库 using Org.BouncyCastle.Crypto.Generators; using Scrypt; using System; using System.Security.Cryptography; namespace …

Python基础教程(九):装饰器

&#x1f49d;&#x1f49d;&#x1f49d;首先&#xff0c;欢迎各位来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里不仅可以有所收获&#xff0c;同时也能感受到一份轻松欢乐的氛围&#xff0c;祝你生活愉快&#xff01; &#x1f49d;&#x1f49…

强大的.NET的word模版引擎NVeloDocx

在Javer的世界里&#xff0c;存在了一些看起来还不错的模版引擎&#xff0c;比如poi-tl看起来就很不错&#xff0c;但是那是人家Javer们专属的&#xff0c;与我们.Neter关系不大。.NET的世界里Word模版引擎完全是一个空白。 很多人不得不采用使用Word XML结合其他的模版引擎来…

怎样快速获取Vmware VCP 证书,线上考试,voucher报名优惠

之前考一个VCP证书&#xff0c;要花大一万的费用&#xff0c;可贵了&#xff0c;考试费不贵&#xff0c;贵就贵在培训费&#xff0c;要拿到证书&#xff0c;必须交培训费&#xff0c;即使vmware你玩的很溜&#xff0c;不需要再培训了&#xff0c;但是一笔贵到肉疼的培训费你得拿…

嵌入式Linux系统编程 — 3.4 access、chmod和 umask函数修改文件访问权限

目录 1 文件访问权限 1.1 文件权限基本概念 1.2 普通权限 1.3 特殊权限 2 目录权限 3 access函数检查文件权限 3.1 access函数简介 3.2 示例程序 3.3 chmod修改文件权限 3.4 fchmod函数 4 umask 函数 4.1 umask简介 4.2 示例程序 1 文件访问权限 1.1 文件权限基本…

奇安信停服,国内还有什么可用的高防么?

这里写自定义目录标题 背景DDOS怎么办&#xff1f;方案推荐总结 背景 继前段时间百度云加速通知免费服务&#xff0c;6月底奇安信也将停止服务&#xff0c;到时候国内将几乎不存在免费好用的高防CDN了&#xff1b;类似的事情还有阿里云和腾讯云的一年期免费SSl证书也都停止供应…