说明:
安装包提取
链接:https://pan.baidu.com/s/1tgV7quXOVI1b0Ha3H72o1Q
提取码:hrxg
centos7.4升级Openssh服务
将7-8sshupdate.sh、openssh-8.9p1.tar.gz、openssl-1.1.1f.tar.gz上传至/media目录
第一步:升级Openssh服务
执行sh 7-8sshupdate.sh,其中会有30秒暂停查看ssl版本信息是否为OpenSSL 1.1.1f ,执行完成后,重启服务器,命令为:reboot
第二步:验证服务
重启能否正常连接服务器,查看xftp功能是否正常。
第三步:关闭telnet服务
再确认SSH服务没有问题的情况下,关闭telnet服务,执行命令:systemctl disable telnet.socket
systemctl stop telnet.socket
#!/bin/bash
##################创建用户##########################
id_jxj=`cat /etc/passwd|grep jxj|awk -F ':' '{print $1}'`
if [ "$id_jxj" != "jxj" ];then
groupadd -g 600 jxj
useradd -u 600 jxj -g jxj
echo "123456" | passwd --stdin jxj
fi
#######################安装依赖包###########################
yum clean all
yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel vim
yum -y install telnet-server.x86_64 telnet.x86_64
#######################设置开机自启######################
systemctl enable telnet.socket
systemctl start telnet.socket
##########################升级openssl##########################
tar -xvf /media/openssl-1.1.1f.tar.gz -C /media > /dev/null 2>&1
cd /media/openssl-1.1.1f
./config --prefix=/usr/local/openssl
if [ $? -ne 0 ]
then
echo "command faild"
exit 0
else
make -j8 && make install
fi
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl/ /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
openssl version
sleep 30
########################升级openssh#####################
mv /etc/ssh/ /etc/ssh.old
mkdir ssh
tar -xvf /media/openssh-8.9p1.tar.gz -C /media > /dev/null 2>&1
cd /media/openssh-8.9p1
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl --with-zlib --with-md5-passwords --with-pam
if [ $? -ne 0 ]
then
echo "command faild"
exit 0
else
make -j8 && make install
fi
echo "UseDNS no" >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
cp -a /media/openssh-8.9p1/contrib/redhat/sshd.init /etc/init.d/sshd
cp -a /media/openssh-8.9p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd
chkconfig --add sshd
systemctl enable sshd
mv /usr/lib/systemd/system/sshd.service /media
chkconfig sshd on
###启动命令 systemctl start sshd##############
###########修改端口#################
sed -i 's/\#Port\ 22/Port\ 30000/g' /etc/ssh/sshd_config