升级openssh
1、安装依赖包
apt install libzip-dev libssl-dev autoconf gcc libxml2 make -y
2、下载源码文件包
cd /usr/local/src wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.1p1.tar.gz wget https://www.openssl.org/source/openssl-1.1.1.tar.gz --no-check-certificate wget http://www.zlib.net/zlib-1.2.11.tar.gz tar -zxvf openssh-8.1p1.tar.gz tar -zxvf openssl-1.1.1.tar.gz tar -zxvf zlib-1.2.11.tar.gz
3、编译安装zlib
上传zlib源码到服务器的任意目录,并解压 cd zlib-1.2.11 ./configure --prefix=/usr/local/zlib make && make install 更新动态链接数据库 echo "/usr/local/zlib/lib" >> /etc/ld.so.conf ldconfig -v
4、编译安装openssl
apt purge openssl
cd ../openssl-1.1.1 ./config shared --prefix=/usr/local/ssl make test make install ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1 ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1 echo "/usr/local/ssl/lib" > /etc/ld.so.conf.d/openssl.conf mv /usr/include/openssl /usr/include/openssl.bak
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/ssl/bin/openssl /usr/bin/
ldconfig -v
查询openssl版本号
openssl version -a
5、编译安装openssh
mkdir /tmp/ssh_bak -p mkdir /tmp/ssh_bak/init.d -p cp -r /etc/ssh /tmp/ssh_bak cp /etc/init.d/ssh /tmp/ssh_bak/init.d service sshd stop #apt-get remove openssh-server openssh-client -y apt-get purge openssh-server openssh-client -y #rm -rf /etc/init.d/ssh #mv /etc/ssh /etc/ssh.bak cd ../openssh-8.1p1 ./configure --prefix=/usr/local/ssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl
make make instal
6、设置相关配置文件
mv /usr/bin/scp /tmp/ mv /usr/bin/ssh* /tmp/ ln -s /usr/local/ssh/bin/ssh /usr/bin/ssh ln -s /usr/local/ssh/bin/scp /usr/bin/scp ln -s /usr/local/ssh/bin/ssh-add /usr/bin/ssh-add ln -s /usr/local/ssh/bin/ssh-agent /usr/bin/ssh-agent ln -s /usr/local/ssh/bin/ssh-keygen /usr/bin/ssh-keygen ln -s /usr/local/ssh/bin/ssh-keyscan /usr/bin/ssh-keyscan ln -s /usr/local/ssh/sbin/sshd /usr/bin/sshd
ln -s /usr/local/ssh/sbin/sshd /usr/sbin/sshd
执行ssh -V验证是否升级成功 ssh -V
7、重启ssh服务
systemctl enable ssh systemctl restart ssh
8、查看当前版本
ssh -V