Centos7 OpenSSH漏洞整改 |
您所在的位置:网站首页 › 高危漏洞修复不了怎么办 › Centos7 OpenSSH漏洞整改 |
OpenSSHow漏洞风险提示,因此需要进行升级整改 ![]() 1、查看是否已经安装telnet服务 [root@localhost ~]# rpm -qa|grep telnet [root@localhost ~]# rpm -qa|grep xinetd2、yum安装 [root@localhost ~]# yum -y install telnet* [root@localhost ~]# yum -y install xinetd3、启动telnet服务并设置自动启动 [root@localhost ~]# systemctl enable xinetd.service [root@localhost ~]# systemctl start xinetd.service [root@localhost ~]# systemctl enable telnet.socket [root@localhost ~]# systemctl start telnet.socket4、添加 #在文本最后添加 [root@localhost ~]# vi /etc/securetty pts/0 pts/1 pts/2 #查看 [root@localhost ~]# tail -3 /etc/securetty pts/0 pts/1 pts/25、重启服务并查看端口 [root@localhost ~]# systemctl restart xinetd [root@localhost ~]# ss -ntlp|grep 23 LISTEN 0 128 :::23 :::* users:(("systemd",pid=1,fd=43)) 二、升级OpenSSl1、查看系统原版本 [root@localhost ~]# openssl version OpenSSL 1.0.2k-fips 26 Jan 20172、下载https://ftp.openssl.org/source/ 3、安装依赖包 [root@localhost ~]# yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel pam* zlib*4、解压 [root@localhost ~]# tar zxvf openssl-1.1.1k.tar.gz5、检测环境 [root@localhost ~]# cd openssl-1.1.1k [root@localhost openssl-1.1.1k]# ./config --prefix=/usr/local/openssl6、编译并安装 [root@localhost openssl-1.1.1k]# make && make install7、替换当前系统的旧版本openssl(先保存原来的) [root@localhost openssl-1.1.1k]# which openssl /usr/bin/openssl [root@localhost openssl-1.1.1k]# mv /usr/bin/openssl /usr/bin/openssl.old [root@localhost openssl-1.1.1k]# mv /usr/lib64/openssl /usr/lib64/openssl.old [root@localhost openssl-1.1.1k]# mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old [root@localhost openssl-1.1.1k]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl [root@localhost openssl-1.1.1k]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl [root@localhost openssl-1.1.1k]# ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so [root@localhost openssl-1.1.1k]# echo "/usr/local/openssl/lib" >> /etc/ld.so.conf [root@localhost openssl-1.1.1k]# ldconfig -v8、确认版本 1、查看系统原版本 [root@localhost ~]# ssh -V OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 20172、下载https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/ 3、解压 [root@localhost ~]# tar zxvf openssh-8.6p1.tar.gz4、移除旧版本 #移除之后,不能退出当前终端。若退出,只能通过telnet连接 [root@localhost ~]# mv /etc/ssh /etc/ssh.old5、编译并安装 [root@localhost ~]# cd openssh-8.6p1 [root@localhost openssh-8.6p1]# ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib --without-hardening [root@localhost openssh-8.6p1]# make && make install6、修改启动脚本 #拷贝启动脚本 [root@localhost openssh-8.6p1]# cp ./contrib/redhat/sshd.init /etc/init.d/sshd #修改启动脚本 [root@localhost openssh-8.6p1]# vi /etc/init.d/sshd #按如下图修改,需要注意,此路径是你安装新版本的openssh路径,根据你的实际情况修改 SSHD=/usr/local/openssh/sbin/sshd7、修改sshd配置文件/etc/ssh/sshd_config #直接用root登录终端(此处根据自身情况考虑) [root@localhost openssh-8.6p1]# echo "PermitRootLogin yes" >> /etc/ssh/sshd_config #设置是否允许X11转发 [root@localhost openssh-8.6p1]# echo 'X11Forwarding yes' >> /etc/ssh/sshd_config #是否允许密码验证 [root@localhost openssh-8.6p1]# echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config8、卸载原有ssh(先安装后卸载,也是怕升级失败) for i in $(rpm -qa |grep openssh);do rpm -e $i --nodeps ;done提示告警 将警告中被修改的文件名字再改回来 [root@localhost ~]# mv /etc/ssh/ssh_config.rpmsave /etc/ssh/ssh_config [root@localhost ~]# mv /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config [root@localhost ~]# mv /etc/ssh/moduli.rpmsave /etc/ssh/moduli9、替换相关命令,并重启sshd服务 [root@localhost ~]# cp -arp /usr/local/openssh/bin/* /usr/bin/ [root@localhost ~]# systemctl restart sshd10、验证升级版本 11、设置开机启动 [root@localhost ~]# systemctl enable sshd12、ssh正常登陆之后为了系统安全,需要停用telnet服务 [root@localhost ~]# systemctl stop xinetd [root@localhost ~]# systemctl disable xinetd [root@localhost ~]# systemctl stop telnet.socket [root@localhost ~]# systemctl disable telnet.socket 四、隐藏openssh版本号修改ssh默认端口之后,版本号也想隐藏 1、(重点)要在执行编译步骤之前修改version.h文件 [root@localhost ~]# cd openssh-8.6p1 [root@localhost openssh-8.6p1]# vi version.h /* $OpenBSD: version.h,v 1.90 2021/04/16 03:42:00 djm Exp $ */ #define SSH_VERSION "OpenSSH_8.6" #define SSH_PORTABLE "p1" #define SSH_RELEASE SSH_VERSION SSH_PORTABLE修改前,删除版本号 修改后 2、接着按照第三大点执行编译和后面的步骤即可 3、再次查看已经没有版本号 4、再次扫描查看
|
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |