升级包地址
https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/openssh-9.9.tar.gz
- [x] 云服务器/虚拟机:控制台进行升级
- [x] 物理服务器:远程管理卡升级
- [x] openssh 的升级会影响到 ssh 的连接
下载解压
[root@localhost ~]# wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/openssh-9.9.tar.gz
[root@localhost ~]# tar -zxvf openssh-9.9.tar.gz
编译工具套件安装
[root@localhost ~]# dnf -y install gcc
[root@localhost ~]# dnf -y install gcc-c++
[root@localhost ~]# dnf -y install make
[root@localhost ~]# dnf -y install openssl-devel
备份配置文件
[root@localhost ~]# mv /etc/ssh{,.bak}
[root@localhost openssh-9.9p1]# ./configure --help
[root@localhost openssh-9.9p1]# ./configure --sysconfdir=/etc/ssh
[root@localhost openssh-9.9p1]# make -j2 #2 2个CPU的意思
[root@localhost openssh-9.9p1]# make install
[root@localhost openssh-9.9p1]# ssh -V
备份ssh
[root@localhost openssh-9.9p1]# mv /usr/bin/scp /usr/bin/scp.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/sftp /usr/bin/sftp.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/ssh /usr/bin/ssh.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/ssh-add /usr/bin/ssh-add.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/ssh-agent /usr/bin/ssh-agent.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
[root@localhost openssh-9.9p1]# mv /usr/bin/ssh-keyscan /usr/bin/ssh-keyscan.bak
[root@localhost openssh-9.9p1]# mv /usr/sbin/sshd /usr/sbin/sshd.bak
[root@localhost ~]# cp /usr/local/bin/ssh /usr/bin/
[root@localhost ~]# cp /usr/local/bin/ssh-add /usr/bin/
[root@localhost ~]# cp /usr/local/bin/ssh-agent /usr/bin/
[root@localhost ~]# cp /usr/local/bin/ssh-keygen /usr/bin/
[root@localhost ~]# cp /usr/local/bin/ssh-keyscan /usr/bin/
[root@localhost ~]# mv /usr/sbin/sshd{,.bak}
[root@localhost bin]# cp /usr/local/sbin/sshd /usr/bin/
[root@localhost bin]# cp /usr/local/sbin/sshd /usr/sbin/
[root@localhost ~]# mv /usr/lib/systemd/system/sshd{,.bak}
[root@localhost ~]# mv /usr/lib/systemd/system/sshd.service{,.bak}
[root@localhost ~]# vim /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=sshd-keygen.target
[Service]
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config
EnvironmentFile=-/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -f /etc/ssh/sshd_config -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload
Comments NOTHING