#!/bin/sh
cd /etc/yum.repos.d
mkdir backup
mv Cent* backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
yum -y clean all
yum -y makecache
yum -y install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel
mkdir /tmp/update
cd /tmp/update
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1q.tar.gz
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz
tar xf openssl-1.1.1q.tar.gz
tar xf openssh-9.0p1.tar.gz
mv /usr/bin/openssl{,.bak}
mv /usr/include/openssl{,.bak}
cd openssl-1.1.1q/
./config shared && make && make install
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/include/openssl/ /usr/include/openssl
echo "/usr/local/lib64" >> /etc/ld.so.conf
mv /etc/ssh{,.bak}
mkdir /usr/local/openssh
cd /tmp/update/openssh-9.0p1/
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/include --with-ssl-dir=/usr/local/lib64 --with-zlib --with-md5-passwords --with-pam --without-openssl-header-check&& make && make install
echo "UseDNS no" >> /etc/ssh/sshd_config
echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config
mv /usr/sbin/sshd{,.bak}
mv /usr/bin/ssh{,.bak}
mv /usr/bin/ssh-keygen{,.bak}
ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd
ssh -V
systemctl disable sshd --now
mv /usr/lib/systemd/system/sshd.service{,.bak}
systemctl daemon-reload
cd /tmp/update
cp -a openssh-9.0p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp -a openssh-9.0p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chkconfig --add sshd
systemctl enable sshd --now
systemctl start sshd
systemctl status sshd
#关闭selinux vi /etc/linux/config 手工
#修改SELINUX=enforce为SELINUX=disable 重启服务器后
restorecon -r -v /root/.ssh
#开启selinux vi /etc/linux/config 手工
#修改为SELINUX=enforcing
systemctl start sshd
标签:sshd,p1,centos8.3,openssl,etc,openssh8.0,usr,--,ssh
From: https://blog.51cto.com/u_14775406/6581736