Centos7.9升级openssh9.0

1.备份
cp -rp /etc/ssh /etc/ssh.bak
2.准备
yum install -y openssl openssl-devel gcc gcc-c++ make zlib-devel
rpm -e   --nodeps `rpm -qa | grep openssh`
3.下载openssh包
cd /root
wget https://mirrors.aliyun.com/openssh/openssh-9.0.tar.gz?spm=a2c6h.25603864.0.0.27b368eexAJ1UM
4.解压安装
tar -zxvf openssh-9.0p1.tar.gz -C ./
cd openssh-9.0p1/
./configure --prefix=/usr/ --sysconfdir=/etc/ssh/ --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man/
make && make install
6.配置systemctl管理
cat >/usr/lib/systemd/system/sshd.service<<EOF
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target
[Service]
ExecStart=/usr/sbin/sshd
[Install]
WantedBy=multi-user.target
EOF
7.解决报错与允许root用户登录

Centos7.9升级openssh9.0_第1张图片

sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin  yes/g' /etc/ssh/sshd_config
chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key
8.启动
systemctl enable sshd
systemctl start sshd
9.检查
# 查看openssh版本,可能需要重新开启终端
ssh -V

你可能感兴趣的:(系统运维,linux,bash,ssh)