ubuntu 20.04.6 LTS (Focal Fossa) 升级openssh9.6p1,zlib1.3,openssl3.2.0

发布时间 2023-12-29 10:50:05作者: 剑小秀

# 卸载openssh

apt-get remove openssh-server openssh-client -y

 

# 更新 APT 软件包列表

apt-get update -y

 

# 安装 libpam0g-dev和gcc

apt-get install libpam0g-dev build-essential -y

 

# 安装zlib

tar -zxvf zlib-1.3tar.gz
./configure --shared
make && make install

 

# 安装OpenSSL

./config shared zlib 
make -j 4 && make install

 

# 备份openssl

mv /usr/bin/openssl /usr/bin/openssl.bak

 

# 从安装位置创建软连接到系统位置

ln -s /usr/local/bin/openssl /usr/bin/openssl

 

# 从用户库创建软链接到openssl安装位置的库目录下(如果目录不存在需要先创建)

ln -s /usr/local/lib64/libssl.so /usr/local/openssl/lib64/libssl.so
ln -s /usr/local/lib64/libssl.so.3 /usr/lib/libssl.so.3
ln -s /usr/local/lib64/libcrypto.so.3 /usr/lib/libcrypto.so.3

 

# 将openssl 的lib 库添加到系统

echo '/usr/local/openssl/lib64' > /etc/ld.so.conf.d/openssl.conf

 

# 使新添加的lib 被系统找到

ldconfig -v

 

# 验证版本

openssl version

 

# 安装openssh

./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-ssl-dir=/usr/include/openssl --with-privsep-path=/var/lib/sshd
make -j 4 && make install

 

# 验证版本

ssh -V

 

# 取消SSH服务的解锁状态,重启sshd服务

systemctl unmask ssh
systemctl restart sshd

 

# 修改sshd_config中sftp路径

find / -name sftp-server #找到路径,一般为:/usr/libexec/sftp-server
cat -n /etc/ssh/sshd_config | grep sftp # 找到sftp在配置文件所在的行号
vim /etc/ssh/sshd_config 找到对应的行,把路径替换为刚找到的就行。