一、下載資源
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