centos7 升级 openssh 到 8.4

一、下载资源

wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz 也可以直接下载:wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz

wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz 也可以直接下载:wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz

二、安装openssl

1、卸载 yum remove openssl

2、解压

3、在解压目录下执行

./config --prefix=/usr/local/ssl -d shared 
make -j 4 && make install
echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

/sbin/ldconfig
openssl version
#能够查看到版本号则说明安装成功。
三、安装openssh
1、卸载原来的openssh
yum remove openssh
2、解压缩
3、在解压目录下执行
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib 
make -j 4 && make install
echo "X11Forwarding yes" >> /etc/ssh/sshd_config
echo "X11UseLocalhost no" >> /etc/ssh/sshd_config                
echo "XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_config
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 /usr/sbin/sshd.bak
cp -rf /usr/local/openssh/sbin/sshd /usr/sbin/sshd
mv /usr/bin/ssh /usr/bin/ssh.bak
cp -rf /usr/local/openssh/bin/ssh /usr/bin/ssh 
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
cp -rf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
#查看版本
ssh -V
3、添加服务到systemctl
cp contrib/redhat/sshd.init /etc/init.d/ chmod +x /etc/init.d/sshd.init
/etc/init.d/sshd.init start
cp /run/systemd/generator.late/sshd.init.service /usr/lib/systemd/system/sshd.service
/etc/init.d/sshd.init stop
systemctl enable sshd
systemctl start sshd