centos7 系统升级 openssh-8.9p1 方法

下载源码

卸载系统自带的 openssh

执行卸载命令:

rpm -e `rpm -qa | grep openssh` --nodeps
rm -f /etc/ssh/*

[注意] 不要重启 sshd 服务否则客户端连接工具不能远程连接linux,除非是在本机上操作。

编译安装

  • 安装 gcc
yum install -y gcc
  • 安装 zlib
tar -xvf zlib*.tar.gz
cd zlib*
./configure --prefix=/usr/local/zlib && make && make install
  • 安装 openssl
tar -zxf openssl*.tar.gz
cd openssl*
./config --prefix=/usr/local/openssl -fPIC && make && make install
  • 配置动态库
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf  
ldconfig
  • 安装 openssh
tar -zxvf openssh*.tar.gz
cd openssh*
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl --with-zlib=/usr/local/zlib --with-md5-passwords --without-hardening && make && make install
  • 修改 sshd 脚本文件
cp openssh*/contrib/redhat/sshd.init /etc/init.d/sshd
sed -i 's/\/usr\/sbin\/sshd/\/usr\/local\/openssh\/sbin\/sshd/g' /etc/init.d/sshd
sed -i 's/\/usr\/bin\/ssh-keygen/\/usr\/local\/openssh\/bin\/ssh-keygen/g' /etc/init.d/sshd
  • 修改 sshd 配置文件允许 root 登录
vim /etc/ssh/sshd_config
PermitRootLogin yes
  • 添加 openssh 环境变量
echo "OPENSSH_HOME=/usr/local/openssh" >> /etc/profile
echo "export PATH=\$OPENSSH_HOME/bin:\$PATH" >> /etc/profile
  • 将 sshd 加入到系统服务
chkconfig --add sshd # 添加开机启动
reboot # 重启系统
  • 查看 ssh 版本
ssh -V
OpenSSH_8.9p1, OpenSSL 1.1.1v  1 Aug 2023
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值