惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 接云网络

.Net5开发MQTT服务器 使用Docker搭建MQTT服务器 使用Docker搭建MQTT服务器 在Raspberry Pi上安装Docker MediaAPIController CentOS7 mysql支持中文 设置centos7中的mysql5.7不区分表名大小写有关操作 CentOS7 安装mysql(YUM源方式) centos7下安装nginx CentOS7利用systemctl添加dotnet后台服务 CentOS7利用systemctl添加自定义系统服务 mysql 8.0.13开启远程连接 配置方式 vue 父子组件数据的双向绑定大法 .NET Core 3.0 发布单文件可执行程序 asp.net core In Docker(Image) ASP.NET Core 2.1 使用Docker运行 Debian 8 安装Nginx最新版本 postman 发送json请求 Simple ASP.NET CORE 2.2 App +Vue JS
阿里云=>RHSA-2019:1884-中危: libssh2 安全更新
接云网络 · 2019-11-17 · via 博客园 - 接云网络

由于项目构建时间比较长,近期安全检查发现openssh有漏洞。所以要升级openssh到7.9p1版本。由于ssh用于远程连接,所以要谨慎操作。

建议生成环境要先做测试,之后再在生产环境升级。

1 前期准备

1.1 依赖安装

1、 OpenSSL版本:目前OpenSSH7.9不支持OpenSSH1.1.x以上。否则编译的时候会报错。

2、 Zlib1.1.4或1.2.1.2或更高版本

3、 gcc:因为编译需要gcc

4、 openssl-devel:编译时需要

1.2 注意事项

1、 前期多打开一个xshell窗口。保证连接正常。因为可能出现升级失败。结束后要确定好再关闭。

2、 备份sshd_config配置文件(方便后期使用或者方便升级失败使用)

3、 最好关闭防火墙,如不关闭防火墙请开启ssh需要的端口和telnet需要的端口。如果ssh不是22端口最好打开22端口。因为ssh配置文件默认22端口。所以建议关闭防火墙。

2、升级之后要重建xshell的session不然会出项下面提示


1 安装telnet

1.1 安装telnet

为防止openssh升级失败。所以安装telnet。保证openssh升级失败也可以通过telnet连接服务器,进行恢复操作。并不用去机房。

#yum install -y telnet-server

#yum install -y xinetd 

#systemctl start telnet.socket

#systemctl start  xinetd

默认情况下,系统是不允许root用户telnet远程登录的。如果要使用root用户直接登录,需设置如下内容。或者可以添加一个可以登录的用户,登录并su到root用户。

#echo 'pts/0' >>/etc/securetty

#echo 'pts/1' >>/etc/securetty

#systemctl restart telnet.socket

1.2 验证telnet

确保使用windows或者其他Linux服务器可以telnet到此机器上。并且可以使用root用户。


建议开启telnet和xinetd开机自动启动,避免reboot后连不上Telnet

systemctl enable xinetd.service

systemctl enable telnet.socket

1 安装openssh

1.1 下载openssh

Openssh官网地址:https://www.openssh.com/

http下载地址:https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/

选择openssh-7.9p1.tar.gz进行下载。并上传到服务器上。

1.2 卸载旧的ssh

#cp -r /etc/ssh /etc/ssh.old #备份一些之前的文件
#rpm -qa|grep openssh
#rpm -e --nodeps openssh-clients-6.6.1p1-31.el7.x86_64
#rpm -e --nodeps openssh-6.6.1p1-31.el7.x86_64
#rpm -e --nodeps openssh-server-6.6.1p1-31.el7.x86_64
#rpm -qa|grep openssh

如果之前就是源码安装的,找到之前的安装包,在里面执行

#make uninstall

1.3 安装OpenSSH

1、连接到其他计算机时,OpenSSH作为两个进程运行。第一个进程是特权进程,并根据需要控制权限的颁发。第二个进程与网络通信。设置适当的环境需要额外的安装步骤,这些步骤通过以root用户身份发出以下命令来执行 :

#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

2、解压安装

#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

如果报错
① configure: error: no acceptable C compiler found in $PATH
问题解决
yum install gcc
② configure: error: * zlib.h missing - please install first or check config.log *
问题解决
yum install openssl openssl-devel -y 安装相关依赖包
3、修改相应文件权限

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

4、安装

#make install

5、配置

#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

命令解释:

--sysconfdir=/etc/ssh:这可以防止安装配置文件 /usr/etc。
--with-md5-passwords:这使得可以使用MD5密码。
--with-pam:此参数在构建中启用 Linux-PAM支持。
--with-xauth=/usr/bin/xauth:为X身份验证设置xauth二进制文件的默认位置。如果将xauth安装到其他路径,请更改位置。这也可以sshd_config使用XAuthLocation关键字进行控制。如果已安装Xorg,则可以省略此开关。
--with-kerberos5=/usr:此选项用于在构建中包含Kerberos 5支持。
--with-libedit:此选项为sftp启用行编辑和历史记录功能。

6、根据自身需求改写配置文件。因为配置文件为初始配置文件。所以和之前的不一样。可以使用备份配置文件覆盖。

注意:默认是22端口,但是不能root直接登录。如果想直接使用root登录执行以下命令

#echo "PermitRootLogin yes" >> /etc/ssh/sshd_config

2 开机自启动

ssh服务必须开机自启动,不然重启的时候爆炸。

#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

3 验证操作

# ssh -V

OpenSSH_7.9p1, OpenSSL 1.0.2k-fips 26 Jan 2017

使用其他电脑或者其他的xshell等工具连接,验证要谨慎。

4 回滚操作

如果之前是rpm包安装的。并且按照以上步骤操作,可以直接以下命令进行回滚

# yum -y install openssh-clients
# yum -y install openssh-server
# yum -y install openssh

5 结束操作

之前的步骤一定要谨慎查看。查看是否可以连接,会不会出现什么问题。

1、 恢复telnet的禁止root登录特权。如果之前关闭就关闭telnet。

2、 开启防火墙。并验证连接。

3、最后再关闭之前开xshell界面。

6 参考文档

官方文档:

http://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssh.html

作者:橡皮24
链接:https://www.jianshu.com/p/220f7fd908b0
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。