现有的Ubuntu 16.04中默认的openssh为7.2p的版本,在部分客户的系统检测中无法通过安全检测,存在系统漏洞,客户环境要求升级。但现有的官方的编译好的openssh包为7.6版本:
现在最新的openssh版本为7.9版本,要想升级至最新的版本,只能采用源码安装的形式,下面介绍一下安装流程。
1、安装依赖包
apt-get install build-essential
2、下载源码文件包
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.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-7.9p1.tar.gz;tar -zxvf openssl-1.1.1.tar.gz;tar -zxvf zlib-1.2.11.tar.gz
3、编译安装openssl
cd zlib-1.2.11;./configure --prefix=/usr/local
make;make install
apt-get purge openssl
cd openssl-1.1.1
./config --prefix=/usr/local --openssldir=/usr/local/ssl
make test;make install
./config shared --prefix=/usr/local --openssldir=/usr/local/ssl
make clean;make;make install
ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
4、编译安装openssh
cd openssh-7.9p1
./configure -prefix=/usr/local -sysconfdir=/etc/ssh -with-ssl-dir=/usr/local/ssl
make;make install
5、设置相关配置文件
mv /usr/bin/scp /tmp/;mv /usr/bin/ssh* /tmp/
ln -s /usr/local/bin/ssh /usr/bin/ssh
ln -s /usr/local/bin/scp /usr/bin/scp
ln -s /usr/local/bin/ssh-add /usr/bin/ssh-add
ln -s /usr/local/bin/ssh-agent /usr/bin/ssh-agent
ln -s /usr/local/bin/ssh-keygen /usr/bin/ssh-keygen
ln -s /usr/local/bin/ssh-keyscan /usr/bin/ssh-keyscan
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/sbin/sshd /usr/bin/sshd
6、重启ssh服务
/etc/init.d/ssh restart