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.

相关推荐
致奋斗的我们3 分钟前
RHCE的学习(7)
linux·服务器·网络·学习·redhat·rhce·rhcsa
petaexpress6 分钟前
云存储的费用是多少?2024年最新价格表
运维·服务器·云存储·云存储的费用是多少·云存储的费用是多少最新·云存储费用
昨天今天明天好多天40 分钟前
【Linux】ClickHouse 部署
linux·服务器·clickhouse
taolichao3040 分钟前
架设一台NFS服务器,按照要求配置
linux·运维·服务器
程序员yt41 分钟前
2025秋招八股文--服务器篇
linux·运维·服务器·c++·后端·面试
2301_8107301042 分钟前
RHCSA基础命令整理1
linux·运维·服务器
稳重的大王42 分钟前
如何使用 NetBak PC Agent 备份和恢复 Windows 计算机或服务器?
运维·服务器
纪伊路上盛名在1 小时前
服务器与服务器之间文件上传下载
运维·服务器
小何学计算机1 小时前
Nginx 配置基于主机名的 Web 服务器
服务器·前端·nginx
云围1 小时前
Soanrquber集成Gitlab 之 导入Gitlab项目
运维·ci/cd·gitlab·devops