OpenSSH主机安全漏洞解决方案

问题描述:OpenSSH 用户枚举漏洞(CVE-2018-15473)【原理扫描】

              OpenSSH do_setup_env函数权限提升漏洞(CVE-2015-8325)

             OpenSSH auth_password函数拒绝服务漏洞(CVE-2016-6515)

              OpenSSH多个拒绝服务漏洞(CVE-2016-10708)

              OpenSSH 安全限制绕过漏洞(CVE-2016-10012)

              OpenSSH 远程代码执行漏洞(CVE-2016-10009)

              OpenSSH 安全漏洞(CVE-2016-1908)

解决方案:OpenSSH升级版本到最新(8.7)版本

具体操作:
1、依赖软件包:

yum install wget gcc -y

yum install -y zlib-devel openssl-devel

yum install pam-devel libselinux-devel zlib-devel openssl-devel -y

2、下载安装包OpenSSH8.7上传至服务器或wget直接下载

wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz

3、删除低版本OpenSSH的的rpm包

rpm -e --nodeps rpm -qa | grep openssh

4、安装openssh

解压

tar -zxvf openssh-8.7p1.tar.gz

cd openssh-8.7p1

./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-tcp-wrappers --with-ssl-dir=/usr/local/ssl --without-hardening

编译安装

make

make install

赋权

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

复制配置文件并设置允许root用户远程登录

cp -a contrib/redhat/sshd.init /etc/init.d/sshd

cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam

chmod u+x /etc/init.d/sshd

vim /etc/ssh/sshd_config

1.修改#PermitRootLogin prohibit-password项,去掉注释#并把prohibit-password改为yes,修改后即为PermitRootLogin yes

2.去掉注释#PasswordAuthentication yes变为PasswordAuthentication yes

添加添加自启服务ssh到开机启动项

chkconfig --add sshd
chkconfig sshd on

重启服务

systemctl restart sshd

查看下安装结果:

ssh -V

注意:高版本升级会导致xshell或者xftp登陆报错

第一步检查/etc/ssh/sshd_config文件中配置

PermitRootLogin yes

PubkeyAuthentication yes

PasswordAuthentication yes

第二步检查是否开启防火墙

setenforce 0

第三步检查/etc/pam.d/sshd文件是否存在

/etc/pam.d/sshd文件必须存在,不存在就无法通过验证

centos7下的/etc/pam.d/sshd文件内容:

#%PAM-1.0

auth required pam_sepermit.so

auth substack password-auth

auth include postlogin

-auth optional pam_reauthorize.so prepare

account required pam_nologin.so

account include password-auth

password include password-auth

session required pam_selinux.so close

session required pam_loginuid.so

session required pam_selinux.so open env_params

session required pam_namespace.so

session optional pam_keyinit.so force revoke

session include password-auth

session include postlogin

-session optional pam_reauthorize.so prepare

(再重启sshd服务systemctl restart sshd)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值