
老版本
root@nginx:~# ssh -V
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n 7 Dec 2017
root@nginx:~# which openssl
/usr/bin/openssl
root@nginx:~# openssl version
OpenSSL 1.1.1 11 Sep 2018
telnet安装,以防失联
apt-get install openbsd-inetd telnetd telnet -y
/etc/init.d/openbsd-inetd restart
netstat -anpt|grep 23
telnet 127.0.0.1
zlib
#官方下载地址: http://www.zlib.net/
wget http://zlib.net/zlib-1.2.11.tar.gz
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make -j 8
make install
openssl
#官方下载地址: https://www.openssl.org/source/,版本分支不要选错
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar zxvf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
#一定要加上shared 参数,要不在安装openssh的时候就无法找到
./config shared zlib
make -j 8
make install
备份原来的openssl,创建软链接到系统位置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/include/openssl /usr/include/openssl
将openssl 的lib 库添加到系统,并使用
echo "/usr/local/lib" > /etc/ld.so.conf.d/openssl.conf
ldconfig
查看openssl版本
root@nginx:~/openssl-1.1.1c# openssl version -a
OpenSSL 1.1.1c 28 May 2019
built on: Tue Jun 11 08:21:44 2019 UTC
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT
-DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUGOPENSSLDIR: "/usr/local/ssl"
ENGINESDIR: "/usr/local/lib/engines-1.1"
Seeding source: os-specific
openssh
备份原openssh文件,卸载原openssh
mv /etc/init.d/ssh /etc/init.d/ssh.old
cp -r /etc/ssh /etc/ssh.old
apt-get remove openssh-server openssh-client -y
安装新版本
apt-get install libpam0g-dev -y
#yum -y install pam-devel
#官方下载地址: https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/
wget --no-check-certificate https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
tar zxvf openssh-8.0p1.tar.gz
cd openssh-8.0p1
./configure --prefix=/usr \
--sysconfdir=/etc/ssh \
--with-md5-passwords \
--with-pam --with-zlib \
--with-ssl-dir=/usr/local \
--with-privsep-path=/var/lib/sshd #需要指定openssl的安装路径
make -j 8
make install
新版本
root@nginx:~/openssh-8.0p1# ssh -V
OpenSSH_8.0p1, OpenSSL 1.1.1c 28 May 2019
还原配置文件
cd /etc/ssh
mv sshd_config sshd_config.default
cp ../ssh.old/sshd_config ./
mv /etc/init.d/ssh.old /etc/init.d/ssh
systemctl unmask ssh
systemctl restart ssh