系统安装完成后,默认安装的openssl跟openssh版本较低,有安全隐患,于是对其进行升级,加固安全,首先升级openssl至1.0.2g版本,升级步骤如下
#!/bin/bash
yum install zlib zlib-devel -y
yum remove openssl-devel
cd /data
wget https://openssl.org/source/openssl-1.0.2g.tar.gz
tar zvxf openssl-1.0.2g.tar.gz
cd openssl-1.0.2g
./config shared zlib
make depend
make && make install
mkdir -pv /tmp/usr/{bin,include}
mv /usr/bin/openssl /tmp/usr/bin/
mv /usr/include/openssl /tmp/usr/include/
ln -sv /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -sv /usr/local/ssl/include/openssl/ /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v | grep openssl
openssl version -a
升级openssl完成后再升级openssh,首先添加普通用户并加入wheel组
groupadd test
useradd tide -g test
usermod -G wheel test
echo "截取以下随机数设置test用户密码,用于升级后登录服务器"
openssl rand -base64 30
passwd tide
只允许wheel用户组的用户su切换,其他用户切换root,即使输对密码也会提示 incorrect password
vim /etc/pam.d/su
auth required pam_wheel.so use_uid取消注释
下载安装openssh7.2版本,该版本成功升级后默认不允许root登录
cd /data
mv /etc/ssh /etc/ssh

为了提高系统安全性,将openssl升级到1.0.2g版本,并详细描述了升级过程。接着升级openssh至7.2版,禁止root直接登录,仅允许通过密钥文件以特定用户登录。此外,设置了登录IP限制、超时断开、减少历史记录、清理history、增强文件权限等多重安全措施。
最低0.47元/天 解锁文章
1875

被折叠的 条评论
为什么被折叠?



