CentOS 7 下升级 OpenSSL + OpenSSH【在线 yum 安装依赖】
文章目录
- CentOS 7 下升级 OpenSSL + OpenSSH【在线 yum 安装依赖】
-
-
- 当前版本查看
-
- 安装 Telnet 防止 ssh 无法登录【yum 安装 && 配置】
-
-
- 安装 telnet-server
- 启动 telnet 服务
- 配置 SELinux && Firewalld 服务
- 测试 Telnet 登录
- 升级 OpenSSL
-
-
- 卸载老版本安装包
- 安装编译依赖包
- 备份 ssh 目录
- 下载 OpenSSL 新版本安装包
- 编译 && 安装 OpenSSL
- 验证安装结果
- 升级 OpenSSH
-
-
- 下载 OpenSSH 新版本安装包
- 解压安装包
- 编译 && 安装 OpenSSH
- 验证安装结果
- 启动 && 验证 ssh 服务
-
-
- 启动服务
- 配置开机启动
- 验证 sshd 开机启动
- 配置 ssh 允许 root 远程登录
- 遇到问题
-
- 参考
当前版本查看
OpenSSH
[root@localhost ~]
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
OpenSSL
[root@localhost ~]
OpenSSL 1.0.2k-fips 26 Jan 2017
安装 Telnet 防止 ssh 无法登录【yum 安装 && 配置】
安装 telnet-server
[root@localhost ~]
Installed:
telnet-server.x86_64 1:0.17-66.el7
Complete!
启动 telnet 服务
[root@localhost ~]
配置 SELinux && Firewalld 服务
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
测试 Telnet 登录
[C:\~]$ telnet 192.168.68.129
Connecting to 192.168.68.129:23...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Kernel 3.10.0-1127.el7.x86_64 on an x86_64
localhost login: root
Password:
Last login: Wed Nov 2 19:48:24 from 192.168.68.1
升级 OpenSSL
卸载老版本安装包
[root@localhost ~]
安装编译依赖包
[root@localhost ~]
Installed:
pam-devel.x86_64 0:1.1.8-23.el7 pam_krb5.x86_64 0:2.4.8-6.el7
pam_pkcs11.x86_64 0:0.6.2-30.el7 pam_snapper.x86_64 0:0.2.8-4.el7
pam_ssh_agent_auth.x86_64 0:0.10.3-2.22.el7_9 zlib-devel.x86_64 0:1.2.7-20.el7_9
zlib-static.x86_64 0:1.2.7-20.el7_9
Dependency Installed:
boost-serialization.x86_64 0:1.53.0-28.el7 pcsc-lite-libs.x86_64 0:1.8.8-8.el7
snapper.x86_64 0:0.2.8-4.el7 snapper-libs.x86_64 0:0.2.8-4.el7
Updated:
zlib.x86_64 0:1.2.7-20.el7_9
Complete!
备份 ssh 目录
[root@localhost ~]
下载 OpenSSL 新版本安装包
[root@localhost ~]
编译 && 安装 OpenSSL
[root@localhost ~]
[root@localhost ~]
[root@localhost openssl-1.1.1s]
Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1s (0x1010113fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile
**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************
[root@localhost openssl-1.1.1s]
验证安装结果
[root@localhost ~]
OpenSSL 1.1.1s 1 Nov 2022
升级 OpenSSH
下载 OpenSSH 新版本安装包
[root@localhost ~]
解压安装包
[root@localhost ~]
编译 && 安装 OpenSSH
[root@localhost ~]
[root@localhost openssh-9.1p1]
[root@localhost openssh-9.1p1]
/bin/mkdir -p /etc/ssh
ssh-keygen: generating new host keys: RSA ECDSA ED25519
/usr/sbin/sshd -t -f /etc/ssh/sshd_config
[root@localhost openssh-9.1p1]
验证安装结果
[root@localhost ~]
OpenSSH_9.1p1, OpenSSL 1.1.1s 1 Nov 2022
启动 && 验证 ssh 服务
启动服务
[root@localhost ~]
Reloading systemd: [ OK ]
Starting sshd (via systemctl): [ OK ]
配置开机启动
[root@localhost ~]
[root@localhost ~]
验证 sshd 开机启动
[root@localhost ~]
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
配置 ssh 允许 root 远程登录
[root@localhost ~]
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
[root@localhost ~]
遇到问题
未关闭 SELinux 导致 ssh 无法登录
Nov 2 23:22:45 localhost sshd[1895]: error: Could not get shadow information for root
Nov 2 23:22:45 localhost sshd[1895]: Failed password for root from 192.168.68.1 port 53566 ssh2
Nov 2 23:22:46 localhost sshd[1895]: error: Received disconnect from 192.168.68.1 port 53566:0: [preauth]
Nov 2 23:22:46 localhost sshd[1895]: Disconnected from authenticating user root 192.168.68.1 port 53566 [preauth]
[root@localhost ~]
参考
- OpenSSH 用户枚举漏洞(CVE-2018-15473) 漏洞处理 – 完全可用