Linux环境漏洞和系统软件升级(汇总)

SW-禁止存在bash漏洞:bash升级

解决方案:目前官方已经提供了升级包请自己下载升级。升级包下载地址:

https://download.csdn.net/download/u013310119/10535274


sw-禁止存在“心脏滴血”漏洞:OpenSSL升级至1.0.2h

openssl版本不在以下列表的则合规,否则不合规则需要升级:
        1.0.1f、1.0.1e、1.0.1d、1.0.1c、1.0.1b、1.0.1a、1.0.1、1.0.2-beta、1.0.2-beta1

https://download.csdn.net/download/u013310119/10535300

如果在执行./config 命令时提示perl版本过低或者没有需要的perl环境,则参考下面链接对应的博客安装perl环境,如果正常编译则跳过:

https://blog.csdn.net/u013310119/article/details/81003526


解决OpenSSH <6.9多重漏洞升级至OpenSSH7.7

第一步:首先需要下载OpenSSH升级所需要的离线安装依赖包。

https://download.csdn.net/download/u013310119/10535330

第二步:按照如下步骤进行升级:

系统环境为:CentOS 6.8 , 

OpenSSH版本为:OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013

目标:升级OpenSSH 到最新版本OpenSSH_7.7p1 (2018-04)

原因:因老版存在很多漏洞,因此需要升级到最新版本。

网络环境:服务器所在区域无法上网,需要离线安装所有软件和依赖包


相关资源:可以通过第一步里的下载连接下载离线升级包。

CentOS 6.8 软件资源:http://vault.centos.org/6.8/os/x86_64/Packages/

OpenSSH 软件资源:https://cloudflare.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/


安装简化步骤:

1. 安装telnet-server  (防止ssh更新时网络断开无法连接)

rpm -ivh telnet-server-0.17-48.el6.x86_64.rpm

2. 安装xinetd

rpm -ivh xinetd-2.3.14-40.el6.x86_64.rpm

将telnet在xinetd的配置中启用

vi /etc/xinetd.d/telnet

    disable         = no     # 启用telnet

service xinetd start   # 启动telnet  

测试telnet是否可用。

3. 备份原始ssh配置  
cp -rf /etc/ssh /etc/ssh.bak


4. 安装vsftpd  (防止sftp 无法使用时,使用ftp传文件)

rpm -ivh vsftpd-2.2.2-21.el6.x86_64.rpm

vsftp的相关配置省略。

5. 安装ftp-client

rpm -ivh ftp-0.17-54.el6.x86_64.rpm

6. 安装openssh相关依赖包和编译环境 

顺序安装gcc, libstdc++-devel,gcc-c++,zlib-devel,keyutils-libs-devel,libcom_err-devel,libsepol-devel,pkgconfig(libsepol),libselinux-devel,krb5-devel,openssl-devel

gcc-4.4.7-17.el6.x86_64.rpm

libstdc++-devel-4.4.7-17.el6.x86_64.rpm

gcc-c++-4.4.7-17.el6.x86_64.rpm 

zlib-devel-1.2.3-29.el6.x86_64.rpm

keyutils-libs-devel-1.4-5.el6.x86_64.rpm

libcom_err-devel-1.41.12-22.el6.x86_64.rpm

libsepol-devel-2.0.41-4.el6.x86_64.rpm

pkgconfig-0.23-9.1.el6.x86_64.rpm

libselinux-devel-2.0.94-7.el6.x86_64.rpm

krb5-devel-1.10.3-57.el6.x86_64.rpm

openssl-devel-1.0.1e-48.el6.x86_64.rpm

7. 卸载旧版ssh( 如果你是通过远程连接登陆Linux主机进行操作的,在卸载了旧版本ssh后,远程连接不会断掉,但是如果关闭了现在的连接,下一次将登陆不进去。
yum remove openssh -y
8. 安装新版ssh
tar -zxvf openssh-7.7p1.tar.gz
cd openssh-7.7p1
./configure( 进行编译的时候,可能会报gcc,zlib错误,虽然上面已经安装了gcc和zlib。但是由于不同的Linux环境对版本要求不一致,需要安装和版本匹配的gcc和zlib。具体问题具体分析。Centos7 需要的gcc为4.8.zlib为最新的。
make

make install

如果openssh不设置安装路径,默认安装路径为:

User binaries: /usr/local/bin
System binaries: /usr/local/sbin
Configuration files: /usr/local/etc
Askpass program: /usr/local/libexec/ssh-askpass
Manual pages: /usr/local/share/man/manX
PID file: /var/run
Privilege separation chroot path: /var/empty

sshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

9. 设置ssh开机启动

将安装源程序目录下的/openssh-7.7p1/contrib/redhat/sshd.init  复制到 /etc/init.d/sshd

vi /etc/init.d/sshd   #修改sshd文件

    SSHD=/usr/local/sbin/sshd
    /usr/local/bin/ssh-keygen -A 
    /sbin/restorecon /usr/local/etc/ssh_host_rsa_key.pub
    /sbin/restorecon /usr/local/etc/ssh_host_dsa_key.pub
    /sbin/restorecon /usr/local/etc/ssh_host_ecdsa_key.pub


将sshd添加到服务
chkconfig --add sshd
允许root远程登录
vim /usr/local/etc/sshd_config     #配置sshd_config文件
    PermitRootLogin yes    #允许root登录
启动sshd服务

service sshd restart

查看ssh的版本

ssh -V

OpenSSH_7.7p1, OpenSSL 1.0.1e-fips 11 Feb 2013

升级后的问题

使用SecureCRT ssh协议连接正常,但使用其他工具无法远程连接操作系统:





解决方法:

处理:

1、要求客户升级SecureCRT版本至6.5或7.x,或更换最新版的Xshell、Putty等工具,即可正常登录(建议使用第一种)

2、修改ssh配置,添加对原加密算法的支持:

修改sshd的配置文件 /etc/ssh/sshd_config

在配置文件中添加:

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,[email protected]

导致此问题的原因是ssh升级后,为了安全,默认不再采用原来一些加密算法,我们手工添加进去即可。

(添加三行或者添加最后一行,重启服务都报错如下)
但重启服务报错如下:
[ root@db ~]# service sshd restart
Stopping sshd:[  OK  ]
Starting sshd:Unsupported KEX algorithm " ecdh-sha2-nistp521"
/etc/ssh/sshd_config line 137: Bad SSH2 KexAlgorithms 'diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1, [email protected]'.
[FAILED]
[ root@db ~]# 

=================================================================

修改为如下:
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc

MACs hmac-md5,hmac-sha1, [email protected],hmac-ripemd160,hmac-sha1-96,hmac-md5-96

KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,diffie-hellman-group1-sha1, [email protected]     (此行中去掉ecdh-sha2-nistp521)

启动sshd服务即可:


使用Xshell4远程登陆linux环境,点击新建文件传输提示:xftp找不到匹配的outgoing encryption 算法 

解决方法如下:

原因,是ssh登录本地终端缓存了相关的安全确认信息

远端的ssh服务升级后,其对应的加密算法均作了升级、修改

而本地的缓存安全信息并无更新,导致无法正常登录

解决方案是 选中aes192-ctr aes128-ctr  aes256-ctr 其中的一个就行



猜你喜欢

转载自blog.csdn.net/u013310119/article/details/81002132
今日推荐