CentOS 8.x 升級 OpenSSH 8.9
阿新 • • 發佈:2022-03-16
VNC 連線至主機,執行以下指令碼(請提前使用 scp 上傳該檔案到主機):
#!/bin/bash set -e echo '1. download openssh source code' cd /usr/local/src rm -rf openssh-8.9p1.tar.gz openssh-8.9p1 curl -O https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.9p1.tar.gz echo '2. install dependency' dnf install wget gcc automake autoconf libtool makezlib-devel openssl-devel pam-devel libselinux-devel -y echo '3. uninstall old version for openssh' rpm -e --nodeps `rpm -qa | grep openssh` echo '4. unpackage openssh source code and configure' tar -zxvf openssh-8.9p1.tar.gz cd openssh-8.9p1 ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --without-hardening echo '5. make and install' make && make install chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key cp -a contrib/redhat/sshd.init /etc/init.d/sshd chmod u+x /etc/init.d/sshd chkconfig --add sshd chkconfig sshd on sed -i 's/#PermitRootLogin prohibit-password/#PermitRootLogin prohibit-password\nPermitRootLogin yes/g' /etc/ssh/sshd_config systemctl restart sshd echo '6. openssh update success, new version is: ' echo $(ssh -V)