首页 > 系统相关 >centos7升级openssh9.3p1

centos7升级openssh9.3p1

时间:2023-03-25 19:12:22浏览次数:129  
标签:sshd p1 openssh centos7 etc host ssh key openssh9.3

centos7升级openssh9.3p1

制作rpm包

安装依赖包

yum install -y rpm-build gcc gcc-c++ glibc glibc-devel openssl-devel openssl pcre-devel zlib zlib-devel make wget krb5-devel pam-devel libX11-devel xmkmf libXt-devel initscripts libXt-devel imake gtk2-devel lrzsz

创建制作rpm相关目录

mkdir -pv /root/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

下载openssh和x11-ssh-askpass安装包

cd /root/rpmbuild/SOURCES/
wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.3p1.tar.gz
tar -xf openssh-9.3p1.tar.gz
#下载x11-ssh-askpass-1.2.4.1.tar.gz
wget https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz

编辑编译配置文件

cp openssh-9.3p1/contrib/redhat/openssh.spec /root/rpmbuild/SPECS/
cd /root/rpmbuild/SPECS/
#不生产ask包
sed -i -e "s/%global no_gnome_askpass 0/%global no_gnome_askpass 1/g" openssh.spec
sed -i -e "s/%global no_x11_askpass 0/%global no_x11_askpass 1/g" openssh.spec
#修改openssl-devel的报错
sed -i '/openssl-devel < 1.1/s/^/#/' openssh.spec
#修改PreReq的报错
sed -i '/PreReq:/s/^/#/' openssh.spec

编译文件

rpmbuild -ba openssh.spec
#生产rpm文件
[root@localhost SPECS]# ls /root/rpmbuild/RPMS/x86_64/
openssh-9.3p1-1.el7.x86_64.rpm          openssh-debuginfo-9.3p1-1.el7.x86_64.rpm
openssh-clients-9.3p1-1.el7.x86_64.rpm  openssh-server-9.3p1-1.el7.x86_64.rpm

升级openssh

yum localinstall openssh-9.3p1-1.el7.x86_64.rpm openssh-clients-9.3p1-1.el7.x86_64.rpm openssh-server-9.3p1-1.el7.x86_64.rpm -y

验证openssh是否升级成功

#修改文件权限
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key

#检查是否有配置错误
sshd -t
#/etc/pam.d/sshd配置丢失,从其他机器拷贝一份配置过来

#注释掉/etc/pam.d/password-auth /etc/pam.d/system-auth中uid >= 1000的行,否则root不能登陆
sed -i '/uid < 1000/s/^/#/' /etc/pam.d/password-auth
sed -i '/uid < 1000/s/^/#/' /etc/pam.d/system-auth

#修改/etc/ssh/sshd_config
sed -i '/^#PermitRootLogin yes/s/^#//' /etc/ssh/sshd_config

#重启sshd服务
systemctl restart sshd

遇到的问题

读写权限不对

现象

[root@localhost x86_64]# sshd -t
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_rsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.

解决方法

chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key

重启后服务正常,但是无法正常登陆

现象

Mar 25 17:44:22 localhost sshd[56496]: PAM adding faulty module: /usr/lib64/security/pam_stack.so

[root@localhost x86_64]# tail -f /var/log/secure
Mar 25 17:44:10 localhost polkitd[584]: Registered Authentication Agent for unix-process:56480:1949117 (system bus name :1.71 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8)
Mar 25 17:44:10 localhost sshd[56494]: Server listening on 0.0.0.0 port 22.
Mar 25 17:44:10 localhost sshd[56494]: Server listening on :: port 22.
Mar 25 17:44:10 localhost polkitd[584]: Unregistered Authentication Agent for unix-process:56480:1949117 (system bus name :1.71, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8) (disconnected from bus)
Mar 25 17:44:22 localhost sshd[56496]: PAM unable to dlopen(/usr/lib64/security/pam_stack.so): /usr/lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
Mar 25 17:44:22 localhost sshd[56496]: PAM adding faulty module: /usr/lib64/security/pam_stack.so
Mar 25 17:44:22 localhost sshd[56496]: Failed password for root from 192.168.184.1 port 2515 ssh2
Mar 25 17:44:25 localhost sshd[56496]: Failed password for root from 192.168.184.1 port 2515 ssh2
Mar 25 17:44:27 localhost sshd[56496]: Failed password for root from 192.168.184.1 port 2515 ssh2
Mar 25 17:44:27 localhost sshd[56496]: Connection closed by authenticating user root 192.168.184.1 port 2515 [preauth]

解决方法

[root@localhost pam.d]# grep pam_stack.so *
sshd:auth       required     pam_stack.so service=system-auth
sshd:account    required     pam_stack.so service=system-auth
sshd:password   required     pam_stack.so service=system-auth
sshd:session    required     pam_stack.so service=system-auth
#查找在那个配置文件中启用了改模块。注释改行配置
[root@localhost pam.d]# grep pam_stack.so * -l
sshd

标签:sshd,p1,openssh,centos7,etc,host,ssh,key,openssh9.3
From: https://www.cnblogs.com/cynriczgc/p/17255368.html

相关文章

  • centos7设置jar包开机自启动
    在linux运行jar包的命令是java -jar xxx.jar如果想要在后台运行的话就加&,终端退出后命令仍旧执行java-jarxxx.jar&这样退出当前远程登录界面这个jar包也......
  • centos7安装Docker(转)
    原文:https://cloud.tencent.com/developer/article/17014511、安装前必读在安装Docker之前,先说一下配置,我这里是Centos7Linux内核:官方建议3.10以上,3.8以上貌似也可......
  • 数组模拟双向列表 洛谷 P1160 队列安排
    题目描述一个学校里老师要将班上N个同学排成一列,同学被编号为1~N,他采取如下的方法:1.先将1号同学安排进队列,这时队列中只有他一个人;2.2~N号同学依次入列,编号为i的同学入列方式......
  • linux (CentOS7.5_x86_64)下安装mysql8.0
    #下载mysql$wgethttp://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-8.0.13-el7-x86_64.tar.gz#解压$mysqltar-zxvfmysql-8.0.4-rc-linux-glibc2.12-x86_6......
  • P1853 投资的最大效益 题解
    题目传送门更好的阅读体验题目大意有初始总资产\(s\)和债券种数\(d\),每种债券有投资额和年利息,求\(n\)年后的最大总资产。解题思路完全背包问题(每种债券可以投资......
  • Centos7扩充root分区
    前言安装Centos7系统的时候,如果没有自定义分区,系统默认分配给root分区的空间只有50G,其它空间都分配给了我们创建的普通用户的home分区。我们可以使用df-h命令来查看各个......
  • P1036 [NOIP2002 普及组] 选数
    [NOIP2002普及组]选数洛谷传送门点击查看题目题目描述已知n个整数x1,x2,.....,xn,以及1个整数k(k<n)。从n个整数中任选k个整数相加,可分别得到一系列的和。例......
  • P1 命令行连接到MySql
    使用命令行窗口连接MySQL数据库mysql-h主机名-P端口-u用户名-p密码注意:(1)“-p密码”之间不要有空格(2)-p后面如果没有写密码,回车会要求输入密码(3)如果......
  • centos7 yum 安装nodejs 16,搭建编译vue项目环境
    1、安装nodejscurl-fsSLhttps://rpm.nodesource.com/setup_16.x|sudobash-sudoyuminstallnodejsnode-v2、安装yarn#安装yarnnpminstall-gyarn#查......
  • centos7 安装maven3.9
    1、创建目录cd/homemkdirmavencd/maven2、下载包wgethttps://mirrors.cnnic.cn/apache/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz 3、......