Centos7升级到openssh9.9

openssh9.9 是2024.9.20出的最新版ssh。因为客户扫描出一大堆centos7的漏洞,全是这个openssh的,好多补丁,所以索性升级到最新版。

需要自己制作rpm包,这个我是不懂,照这个来:

Linux服务器升级openssh9.9最新版全过程,及遇到问题处理_openssh-server最新版本-CSDN博客

作者没有说明怎么处理异常,我这里是centos7的rpm:

https://download.csdn.net/download/leinchu/89896129

使用方法:

mkdir openssh9

mv openssh9.9.tar.gz openssh9

cd openssh9

tar xfz openssh9.9.tar.gz

rpm -ivh --nodeps --force openssh-9.9p1-1.el7.x86_64.rpm

rpm -ivh --nodeps --force openssh9.9.tar.gz

rpm -ivh --nodeps --force openssh-clients-9.9p1-1.el7.x86_64.rpm

rpm -ivh --nodeps --force openssh-debuginfo-9.9p1-1.el7.x86_64.rpm

rpm -ivh --nodeps --force openssh-server-9.9p1-1.el7.x86_64.rpm

ssh-keygen -A

chmod 600 /etc/ssh/ssh_host_ed25519_key

chown root:root /etc/ssh/ssh_host_ed25519_key

sudo chmod 600 /etc/ssh/ssh_host_rsa_key

chown root:root /etc/ssh/ssh_host_rsa_key

sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key

chown root:root /etc/ssh/ssh_host_ecdsa_key

sshd -t -f /etc/ssh/sshd_config

mv /etc/pam.d/sshd /etc/pam.d/sshdbak

vi /etc/pam.d/sshd

#%PAM-1.0

auth required pam_sepermit.so

auth include password-auth

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 optional pam_keyinit.so force revoke

session include password-auth

systemctl restart sshd


验证:ssh -V

遇到的报错:

Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions

sshd: no hostkeys available -- exiting

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.

Oct 17 11:57:33 snmp sshd[139477]: It is required that your private key files are NOT accessible by others.

Oct 17 11:57:33 snmp sshd[139477]: This private key will be ignored.

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key "/etc/ssh/ssh_host_rsa_key": bad permissions

Oct 17 11:57:33 snmp systemd[1]: sshd.service: main process exited, code=exited, status=1/FAILURE

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key: /etc/ssh/ssh_host_rsa_key

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.

Oct 17 11:57:33 snmp sshd[139477]: It is required that your private key files are NOT accessible by others.

Oct 17 11:57:33 snmp sshd[139477]: This private key will be ignored.

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key: /etc/ssh/ssh_host_ecdsa_key

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: @ WARNING: UNPROTECTED PRIVATE KEY FILE! @

Oct 17 11:57:33 snmp sshd[139477]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Oct 17 11:57:33 snmp sshd[139477]: Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.

Oct 17 11:57:33 snmp sshd[139477]: It is required that your private key files are NOT accessible by others.

Oct 17 11:57:33 snmp sshd[139477]: This private key will be ignored.

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions

Oct 17 11:57:33 snmp sshd[139477]: Unable to load host key: /etc/ssh/ssh_host_ed25519_key

Oct 17 11:57:33 snmp sshd[139477]: sshd: no hostkeys available -- exiting.

Oct 17 11:57:33 snmp systemd[1]: Failed to start OpenSSH server daemon.

-- Subject: Unit sshd.service has failed

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit sshd.service has failed.

--

-- The result is failed.

Oct 17 11:57:33 snmp systemd[1]: Unit sshd.service entered failed state.

Oct 17 11:57:33 snmp systemd[1]: sshd.service failed.

Oct 17 11:57:33 snmp polkitd[7888]: Unregistered Authentication Agent for unix-process:139470:389161800 (system bus name :1.41641, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)

Oct 17 11:58:01 snmp systemd[1]: Created slice User Slice of pcp.

-- Subject: Unit user-994.slice has finished start-up

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit user-994.slice has finished starting up.

--

-- The start-up result is done.

Oct 17 11:58:01 snmp systemd[1]: Started Session 13127 of user pcp.

-- Subject: Unit session-13127.scope has finished start-up

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit session-13127.scope has finished starting up.

--

-- The start-up result is done.

Oct 17 11:58:01 snmp CROND[139602]: (pcp) CMD ( /usr/libexec/pcp/bin/pmie_check -C)

Oct 17 11:58:01 snmp systemd[1]: Removed slice User Slice of pcp.

-- Subject: Unit user-994.slice has finished shutting down

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit user-994.slice has finished shutting down.

相关推荐
Mr_Xuhhh1 小时前
重生之我在学环境变量
linux·运维·服务器·前端·chrome·算法
中云DDoS CC防护蔡蔡2 小时前
微信小程序被攻击怎么选择高防产品
服务器·网络安全·微信小程序·小程序·ddos
HPC_fac130520678163 小时前
以科学计算为切入点:剖析英伟达服务器过热难题
服务器·人工智能·深度学习·机器学习·计算机视觉·数据挖掘·gpu算力
yaoxin5211234 小时前
第二十七章 TCP 客户端 服务器通信 - 连接管理
服务器·网络·tcp/ip
sinat_384241098 小时前
使用 npm 安装 Electron 作为开发依赖
服务器
朝九晚五ฺ8 小时前
【Linux探索学习】第十四弹——进程优先级:深入理解操作系统中的进程优先级
linux·运维·学习
Kkooe10 小时前
GitLab|数据迁移
运维·服务器·git
久醉不在酒10 小时前
MySQL数据库运维及集群搭建
运维·数据库·mysql
虚拟网络工程师11 小时前
【网络系统管理】Centos7——配置主从mariadb服务器案例(下半部分)
运维·服务器·网络·数据库·mariadb
BLEACH-heiqiyihu11 小时前
RedHat7—Linux中kickstart自动安装脚本制作
linux·运维·服务器