确定当前版本号
1 2 3 4 5
| openssl version OpenSSL 1.0.2k-fips 26 Jan 2017
ssh -V OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
|
即将升级为:
- OpenSSL: 1.0.2k-fips -> 1.1.1s(最新稳定版)
- OpenSSH: 7.4p1 -> 9.1p1(最新稳定版)
安装TelnetServer
OpenSSH升级有风险,当SSH服务无法正常启动时,需要通过Telnet远程登录并修复。临时开启Telnet,升版完成后再将期关闭。
直接通过本地yum源安装:
1 2 3 4 5 6 7 8 9
| yum install telnet-server -y
systemctl enable telnet.socket systemctl start telnet.socket
telnet 192.168.23.11
|
由于PAM规则的限制,telnet默认不允许root用户远程登录,最简单且合法的方式是新建一个临时用户,登录后再su到root:
1 2 3 4 5 6 7
| useradd tmpuser passwd tmpuser
telnet -l tmpuser 192.168.23.11 su -
|
下载源码
安全加固需要最新稳定版,而CentOS的yum源中版太旧,所以需要在OpenSSL与OpenSSH官网下载源码编译安装
官网地址:
下载链接:
1 2
| wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.1p1.tar.gz
|
升级OpenSSL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| openssl version
yum install gcc gcc-c++ autoconf automake zlib zlib-devel pcre-devel -y
tar -zxvf openssl-1.1.1s.tar.gz cd openssl-1.1.1s
export LANG=C ./config shared make
mv /usr/bin/openssl /usr/bin/openssl_old
make install
ln -s /usr/local/bin/openssl /usr/bin/openssl ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/ ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/
openssl version
|
升级OpenSSH
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| ssh -V OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
yum install zlib-devel openssl-devel pam-devel -y
tar -zxvf openssh-9.1p1.tar.gz cd openssh-9.1p1
./configure \ --prefix=/usr/ \ --sysconfdir=/etc/ssh \ --with-ssl-dir=/usr/local/lib64/ \ --with-zlib \ --with-pam \ --with-md5-password \ --with-ssl-engine \ --with-selinux
make
mkdir /etc/ssh_old mv /etc/ssh/* /etc/ssh_old/
make install
ssh -V OpenSSH_9.1p1, OpenSSL 1.1.1s 1 Nov 2022
vi /etc/ssh/sshd_config PermitRootLogin yes Port 2205
mv /usr/lib/systemd/system/sshd.service /etc/ssh_old/sshd.service mv /usr/lib/systemd/system/sshd.socket /etc/ssh_old/sshd.socket
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
systemctl daemon-reload systemctl restart sshd systemctl status sshd
ssh root@192.168.23.11 -p2205
|
配置SSH互信
TiDB与DS所在的服务器,需要重新配置SSH互信。其它服务器不需要配置。
1
| ssh-copy-id root@192.168.23.XX
|
关闭TelnetServer
确认OpenSSH升级成功后,关闭TelnetServer,并删除临时用户
1 2 3 4 5 6 7
| systemctl disable telnet.socket systemctl stop telnet.socket systemctl status telnet.socket
userdel tmpuser
|