[root@localhost ~]# cat openssh-update.sh
##!/bin/bash
mkdir /software && cd /software
wget --no-check-certificate https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz
#升级openssl
yum install -y gcc gcc-c++ glibc make automake autoconf zlib zlib-devel
tar xf openssl-1.1.1w.tar.gz && cd openssl-1.1.1w/
./config shared zlib -fPIC --prefix=/usr/local/openssl && make -j 4 && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo '/usr/local/openssl/lib' > /etc/ld.so.conf.d/openssl-x86_64.conf && ldconfig -v && openssl version
#安装Telnet防止升崩了无法登陆
yum install telnet-server telnet xinetd -y
systemctl enable xinetd.service
systemctl enable telnet.socket
systemctl start telnet.socket
systemctl start xinetd
useradd appadmin
echo 123456 | passwd --stdin appadmin
vi /etc/pam.d/remote #注释auth required pam_securetty.so
systemctl restart xinetd
systemctl restart telnet.socket
#升级openssh
cd /software
wget --no-check-certificate https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
systemctl stop sshd
mv /etc/ssh /etc/ssh.bak
mv /usr/sbin/sshd /usr/sbin/sshd.bak
mv /usr/bin/ssh /usr/bin/ssh.bak
yum remove openssh -y
yum install -y pcre-devel perl perl-Test-Simple
tar -zxf openssh-9.8p1.tar.gz && cd openssh-9.8p1/ && ./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/openssl --with-zlib
make -j 4 && make install
rm -f /usr/lib/systemd/system/ssh* && cp contrib/redhat/sshd.init /etc/init.d/sshd
mkdir /etc/ssh
sed -i 's@\#PermitRootLogin@PermitRootLogin@g' /usr/local/openssh/etc/sshd_config
sed -i 's@\#PubkeyAuthentication@PubkeyAuthentication@g' /usr/local/openssh/etc/sshd_config
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
systemctl daemon-reload
systemctl start sshd && systemctl enable sshd
ssh -V
centos7.9升级openssh到9.8p1
于 2024-07-11 16:50:52 首次发布