下载安装包
wget http://www.zlib.net/zlib-1.2.13.tar.gz
wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
wget https://github.com/linux-pam/linux-pam/releases/download/v1.3.1/Linux-PAM-1.3.1.tar.xz
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz
安装必要的编译环境(可选)
sudo apt-get install build-essential
升级或安装Zlib
tar -xzvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
./configure --prefix=/usr/local/zlib
make
sudo make install
安装或升级 Perl
tar -xzf perl-5.16.1.tar.gz
cd perl-5.16.1
./Configure -de
make
sudo make install
perl -v
安装pam-devel
tar -xf Linux-PAM-1.3.1.tar.xz
cd Linux-PAM-1.3.1
./configure
make
sudo make install
安装或升级 OpenSSL
tar -zxvf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q
./config --prefix=/usr/local --openssldir=/usr/local/openssl shared
make
sudo make install
sudo sh -c "echo '/usr/local/ssl/lib' >> /etc/ld.so.conf"
sudo ldconfig -v
openssl version
安装或升级 OpenSSH
tar -zxvf openssh-8.8p1.tar.gz
cd openssh-8.8p1
sudo ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib
sudo make clean
sudo make
sudo make install
配置sshd_config文件
sudo sh -c "echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config"
sudo sh -c "echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config"
sudo sh -c "echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config"
备份原来sshd相应配置文件并复制新文件到指定目录
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
mv /usr/sbin/sshd /usr/sbin/sshd.bak
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
mv /usr/bin/ssh /usr/bin/ssh.bak
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
验证是否升级成功
ssh -V
重启sshd服务
sudo /etc/init.d/ssh restart