centos离线升级OpenSSH

背景:

  • 漏洞扫描大量openssh安全漏洞,需升级openssh的版本
    在这里插入图片描述

软件包下载地址:

http://www.zlib.net/zlib-1.2.13.tar.gz
https://www.openssl.org/source/openssl-1.1.1t.tar.gz
https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p1.tar.gz

下载需要安装的依赖包:

  • 需要在可以访问外网的机器上操作,之后将包放到内网服务器上
yum install --downloadonly --downloaddir=/usr/local/src/offline-package  autoconf rpm-build gcc gcc-c++ glibc glibc-devel openssl-devel openssl prce pcre-devel zlib zlib-devel make wget krb5-devel pam-devel libX11-devel xmkmf libXt-devel initscripts libXt-devel imake gtk2-devel openssl openssl-devel pcre-devel pam-devel zlib-devel 

备份yum源,否则yum安装不成功:

mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
yum clean all

编译安装zlib:

cd /usr/local/src/upgrade-openssh
yum localinstall -y --skip-broken /usr/local/src/offline-package/*.rpm
tar xf zlib-1.2.13.tar.gz
cd /usr/local/src/upgrade-openssh/zlib-1.2.13
./configure --prefix=/usr/local/zlib
make && make install

编译安装openssl:

cd /usr/local/src/upgrade-openssh
tar xf openssl-1.1.1t.tar.gz
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
cd /usr/local/src/upgrade-openssh/openssl-1.1.1t
./config --prefix=/usr/local/openssl
cd openssl-1.1.1t/7 
./config --prefix=/usr/local/openssl
make && make install
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
#验证
openssl version

编译安装openssh:

tar xf openssh-9.3p1.tar.gz 
cd /usr/local/src/upgrade-openssh/openssh-9.3p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-tcp-wrappers --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib --without-hardening
make && make install
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "UseDNS no" >> /etc/ssh/sshd_config
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd
chkconfig --add sshd
systemctl enable sshd
chkconfig sshd on
mv /usr/lib/systemd/system/sshd.service  /tmp
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
chmod 600  /etc/ssh/ssh_host_rsa_key
sed -i 's/GSSAPIAuthentication/#GSSAPIAuthentication/g' /etc/ssh/ssh_config
sed -i 's/GSSAPIAuthentication/#GSSAPIAuthentication/g' /etc/ssh/sshd_config 
systemctl daemon-reload
systemctl restart sshd
#验证
ssh -V
make编译报错1:
/usr/bin/ld: cannot find -lz collect2: error: ld returned 1 exit status

undefined reference to `BIO_f_zlib‘ openssl编译报错
解决:
  make clean //清除上次的make命令所产生的object文件
  make // 重新编译
make编译报错2:
configure: error: *** zlib.h missing - please install first or check config.
解决
  安装zlib或者编译时指定zlib
  yum -y install zlib
  --with-zlib/usr/local/zlib
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值