当前位置: 首页 > web >正文

linux环境openssh升级到openssh-10.0p1

一、新版本SSH下载:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/
编译:

./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/openssl341 --sysconfdir=/etc/ssh --with-pam --with-gssapi --with-rsa --with-rhosts-allowed --with-zlib --with-md5-passwords

在configure openssh时,有参数 --with-pam,会提示:
PAM is enabled. You may need to install a PAM control file for sshd, otherwise password authentication may fail. Example PAM control files can be found in the contrib/subdirectory
就是如果启用PAM,需要有一个控制文件,按照提示的路径找到redhat/sshd.pam,并复制到/etc/pam.d/sshd,在/etc/ssh/sshd_config中设置UsePAM yes。
/etc/pam.d/sshd中内容如下:

# 文件内容如下
#%PAM-1.0
auth	   required	pam_sepermit.so
auth       substack     password-auth
auth       include      postlogin
# Used with polkit to reauthorize users in remote sessions
-auth      optional     pam_reauthorize.so prepare
account    required     pam_nologin.so
account    include      password-auth
password   include      password-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open env_params
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      password-auth
session    include      postlogin
# Used with polkit to reauthorize users in remote sessions
-session   optional     pam_reauthorize.so prepare

/etc/ssh/sshd_config 中设置UsePAM yes

二、替换原openssh
1、备份替换相关文件

mv /usr/sbin/sshd /usr/sbin/sshd_bak
mv /usr/bin/ssh /usr/bin/ssh_bak
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen_bak

2、建立软连接

ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd //建立软连接
ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh //建立软连接
ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen //建立软连接

或复制文件

cp -rf /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp -rf /usr/local/openssh/bin/ssh /usr/bin/ssh
cp -rf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen

三、修改配置:
1、解决Root不能远程SSH登录问题

注释/etc/pam.d/password-auth或/etc/pam.d/password-auth-ac中
#auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success

设置/etc/ssh/sshd_config 中PermitRootLogin yes

四、重启ssh服务:
systemctl restart sshd
如果重启报错Permissions 0640 for’/etc/ssh/*****.key’ are too open.

为文件的权限设置过于宽松执行

chmod -R 600 /etc/ssh

限制权限后再重启ssh服务解决
查询服务状态:
systemctl status sshd.service
备注帐户解锁:
sudo passwd -u root
参考资料:
https://blog.csdn.net/Systemmax20/article/details/140006194
https://blog.csdn.net/Daphnisz/article/details/124040904
https://blog.csdn.net/mayifan0/article/details/73293419
https://blog.csdn.net/weixin_43832230/article/details/119565581
https://www.cnblogs.com/clement-jiao/p/9651406.html
https://blog.csdn.net/zhang546030919/article/details/140550933
https://blog.csdn.net/weixin_43742643/article/details/113559949

http://www.xdnf.cn/news/4398.html

相关文章:

  • RabbitMQ如何保证消息不丢失?
  • 【Leetcode 每日一题 - 扩展】3342. 到达最后一个房间的最少时间 II
  • 什么是 token-level 嵌入
  • JVM局部变量表和操作数栈的内存布局
  • C24-数组
  • MedCLIP-SAMv2 实验计划
  • DevExpressWinForms-AlertControl-使用教程
  • 【计算机视觉】OpenCV项目实战:OpenCV_Position 项目深度解析:基于 OpenCV 的相机定位技术
  • 深入探讨 UDP 协议与多线程 HTTP 服务器
  • python-71-基于pyecharts的通用绘图流程
  • 路由器NAT回流踩坑
  • 边缘计算:开启智能新时代的“秘密武器”
  • 性能比拼: HTTP/2 vs. HTTP/3
  • 基于大模型的输卵管妊娠全流程预测与治疗方案研究报告
  • MCP连接Agent:AI时代的TCP/IP
  • 新能源汽车中的NVM计时与RTC计时:区别与应用详解
  • XSS 攻击:深入剖析“暗藏在网页中的脚本“与防御之道
  • 怎么在非 hadoop 用户下启动 hadoop
  • PBR材质-Unity/Blender/UE
  • hadoop的运行模式
  • Web前端技术栈:从入门到进阶都需要学什么内容
  • 【Prompt工程—文生图】案例大全
  • c# LINQ-Query01
  • C 语言编码规范
  • Ubuntu也开始锈化了?Ubuntu 计划在 25.10 版本开始引入 Rust Coreutils
  • 鸿蒙开发——1.ArkTS声明式开发(UI范式基本语法)
  • kotlin一个函数返回多个值
  • 线性代数之矩阵运算:驱动深度学习模型进化的数学引擎
  • 数据可视化与数据编辑器:直观呈现数据价值
  • 在 Ubuntu 中配置 Samba 实现「特定用户可写,其他用户只读」的共享目录