centos-7升级 openssh-server 到7.9

由于某些傻X的扫描,需要升级openssh-server.

其实不需要升级的,centos7 支持到2024年,如果有什么漏洞,官方肯定会出修复,如果自行安装ssh7.9,那就需要自己进行升级和维护工作。参见:https://unix.stackexchange.com/questions/486153/upgrade-openssh-7-4-to-later-on-rhel

 

主要参考: https://www.jianshu.com/p/220f7fd908b0

此文档提到安装telnet防止升级失败,经过实际检验,如果没有异常,可以不需安装telnet


#准备工作
yum install gcc
yum install openssl openssl-devel -y   #安装依赖包

#下载openssh.地址是:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/

 wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz
#编译 
 tar -zxvf openssh-7.9p1.tar.gz
 cd openssh-7.9p1
 ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-privsep-path=/var/lib/sshd
 make


#安装openssh
 install -v -m700 -d /var/lib/sshd
 chown -v root:sys /var/lib/sshd
 groupadd -g 50 sshd
 useradd -c 'sshd PrivSep' -d /var/lib/sshd -g sshd -s /bin/false -u 50 sshd

 chmod 600 /etc/ssh/ssh_host_rsa_key
 chmod 600 /etc/ssh/ssh_host_ecdsa_key
 chmod 600 /etc/ssh/ssh_host_ed25519_key


 make install

 install -v -m755 contrib/ssh-copy-id /usr/bin
 install -v -m644 contrib/ssh-copy-id.1 /usr/share/man/man1
 install -v -m755 -d /usr/share/doc/openssh-7.9p1
 install -v -m644 INSTALL LICENCE OVERVIEW README* /usr/share/doc/openssh-7.9p1


#允许root登陆
 echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

#开机自启动
 cp -p contrib/redhat/sshd.init /etc/init.d/sshd
 chmod +x /etc/init.d/sshd
 chkconfig --add sshd
 chkconfig sshd on
 chkconfig --list sshd

 systemctl restart sshd

 

  systemctl restart sshd 这一步要注意,如果在登录ssh中发现问题可以执行 systemctl status sshd 查看问题所在
 我遇到的问题是 error: Could not get shadow information for root
 原因是更改ssh端口导致SELINUX 阻止,解决方法是 
  setenforce 0 #临时关闭Selinux
  如果要永久关闭,修改/etc/selinux/config 文件,

将SELINUX=enforcing改为SELINUX=disabled

 #验证操作
 ssh -V
 #输出 OpenSSH_7.9p1, OpenSSL 1.0.2k-fips 26 Jan 2017
 
 
 #回滚 (一旦出错还可以还原)
 yum -y install openssh-clients
 yum -y install openssh-server
 yum -y install openssh

 

参考:

https://www.jianshu.com/p/220f7fd908b0

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

路边闲人2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值