当前位置:   article > 正文

Centos7 升级openssl-1.1.1s及openssh-9.1p1(附脚本)_openssh 9在centos7上

openssh 9在centos7上

主要是上个月openssl出现了漏洞,因此要对服务器的进行升级。建议如果没问题还是尽量别升级。主要步骤是2,脚本内容也只包含升级。1和3是开启和关闭telnet,不建议使用telnet。

1 安装和启动telnet

实际中我没使用telnet,开启有一定的风险。
建议服务器的快照创建实例测试先,可以多开几个ssh远程连接,这样一般问题也不大。

1.1 安装xinetd/telnet-server/vsftpd
yum -y install xinetd
yum -y install telnet-server
yum -y install vsftpd
  • 1
  • 2
  • 3
1.2 修改配置文件vim /etc/xinetd.d/telnet 将disable = yes 改为disable = no
flags = REUSE
socket_type = stream        
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
#disable = yes
disable = no
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
1.3 启动并设置开机自启动
service xinetd restart
service vsftpd restart
systemctl start telnet.socket && systemctl enable telnet.socket
  • 1
  • 2
  • 3
1.4 如果有防火墙,则需要放行23端口(阿里云放行)
firewall-cmd --zone=public --add-port=23/tcp --permanent
  • 1
1.5 使用 telnet 连接服务器时,默认是不允许使用root登陆的,需创建一个用户并赋予sudo权限(若已有用户且有sudo权限可跳过)
# 添加用户并设置密码(centos7为用户名,密码ruijie123,>可修改)
useradd centos7
echo ruijie123 | passwd --stdin centos7
# 增加centos7账号的sudo权限
# 在配置文件 /etc/sudoers 中添加配置,但该文件默认是没>有写权限的,因此需要先增加写权限
chmod u+w /etc/sudoers
vi /etc/sudoers
centos7 ALL=(ALL) ALL
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
1.6 windows下的终端中使用telnet命令来测试连接(端口默认23)
telnet ip地址 23
  • 1
2 执行openssh及openssl编译更新
务必多开几个ssh远程连接!!!!!!防止中间意外断开!!!!!!
2.1 将脚本文件及三个下载的压缩包放到opt目录下(同个目录即可),执行脚本,完成安装

进行脚本文件,脚本文件在4,其他三个压缩包自己下载就好了,也可也不下载,脚本会自动下载。

sh upopenssh.sh
  • 1

升级失败就备份好配置,直接使用yum重装自带的ssh,确认好配置。

确认是开机自启动
chkconfig --list sshd
# sshd   0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭 
  • 1
  • 2
3 关闭telnet,openssh测试正常后删除(若使用telnet,务必关闭)
3.1 关闭telnet及防火墙23端口
service xinetd stop && service vsftpd stop
systemctl stop telnet.socket && systemctl disable telnet.socket
firewall-cmd --remove-port=23/tcp  --permanent 
##### 3.2 卸载telnet
rpm -e telnet-server
  • 1
  • 2
  • 3
  • 4
  • 5
3.3 若之前无配置用户则不需要(非必要)
# 删除用户
userdel -r centos7
# 编辑sudo配置文件,去除对应配置段
vi /etc/sudoers
# 恢复sudo配置文件的权限
chmod u-w /etc/sudoers
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
4 upopenssh.sh 脚本

注意这里的openssl不能用3.0的,3.0需要的依赖是不一样的,会报错;1.x的版本应该都是可以的。
都有做备份处理,升级编译过程失败会还原,不过这个还原效果只是手动测试过,没有实际验证,我都成功了。
ssh配置是保留的,有些地方还需要你们自行修改。

脚本来源Linux OpenSSH-9.0p1最新版升级步骤详细(附脚本)
我自己做了修改,主要就是保留配置和多加一些失败操作的处理。

#!/bin/bash
#
#########################################################
# Function :openssh-9.1p1 and openssl 1.1.1s update     #
# Platform :Centos7.X                                   #
# Version  :1.0                                         #
# Date     :2022-12-12                                  #     
#########################################################
echo ------------------------------------------
echo  openssh-9.1p1 and openssl 1.1.1s update
echo ------------------------------------------
sleep 2
clear
export LANG="en_US.UTF-8"

#版本号(目前最新)
zlib_version="zlib-1.2.13"
openssl_version="openssl-1.1.1s"
openssh_version="openssh-9.1p1"

#安装包地址
file="/opt"

#默认编译路径
default="/usr/local" 
date_time=`date +%Y-%m-%d—%H:%M`

#安装目录
file_install="$file/openssh_install"
file_backup="$file/openssh_backup"
file_log="$file/openssh_log"

#源码包链接
zlib_download="https://www.zlib.net/$zlib_version.tar.gz"
openssl_download="https://www.openssl.org/source/$openssl_version.tar.gz"
openssh_download="https://mirrors.aliyun.com/openssh/portable/$openssh_version.tar.gz"


Install_make() {
	echo 安装进程开始
	sleep 1s
	clear
	Check if user is root
	if [ $(id -u) != "0" ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 当前用户为普通用户,必须使用root用户运行,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 3
		exit
	 fi

	# Check telnet server is enable
	# systemctl restart telnet.socket &&  systemctl restart xinetd
	# ps -ef |grep xinetd | egrep -v grep > /dev/null
	# if [ $? -eq 0 ];then
	# 	echo 检测到telnet服务已启动……
	# 	systemctl enable telnet.socket
	# 	systemctl enable xinetd
	# 	echo $(date +%F-%T)  检测到telnet服务并启动…… >> update.log
	# 	sleep 2
	# else
	# 	echo -e " 请务必启动telnet服务后运行脚本(防止更新失败),脚本退出中......" "\033[31m Error\033[0m"
	# 	sleep 3
	# 	exit
	# fi

	#判断是否安装wget
	echo -e "\033[33m 正在安装Wget...... \033[0m"
	sleep 2
	echo ""
		if ! type wget >/dev/null 2>&1;then
			yum install -y wget
		else
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
			echo -e " wget已经安装了:" "\033[32m Please continue\033[0m"
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
			echo ""
		fi

	#判断是否安装tar
	echo -e "\033[33m 正在安装TAR...... \033[0m"
	sleep 2
	echo ""
		if ! type tar >/dev/null 2>&1;then
			yum install -y tar
		else
			echo ""
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
				echo -e " tar已经安装了:" "\033[32m Please continue\033[0m"
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
			echo ""
		fi

	#安装相关依赖包
	echo -e "\033[33m 正在安装依赖包...... \033[0m"
	sleep 3
	echo ""
		yum -y install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel zlib-devel tcp_wrappers-devel tcp_wrappers
		if [ $? -eq 0 ];then
			echo ""
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
				echo -e " 安装软件依赖包成功 " "\033[32m Success\033[0m"
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
			else
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
				echo -e " 解压源码包失败,脚本退出中......" "\033[31m Error\033[0m"
			echo -e "\033[33m--------------------------------------------------------------- \033[0m"
			echo ""
			sleep 4
			exit
		fi
}


Install_backup() {
	#创建文件(可修改)
	mkdir -p $file_install
	mkdir -p $file_backup
	mkdir -p $file_log
	mkdir -p $file_backup/zlib
	mkdir -p $file_backup/ssl
	mkdir -p $file_backup/ssh
	mkdir -p $file_log/zlib
	mkdir -p $file_log/ssl
	mkdir -p $file_log/ssh

	#备份文件(可修改)
	cp -rf /usr/bin/openssl  $file_backup/ssl/openssl_$date_time.bak > /dev/null
	cp -rf /usr/include/openssl /usr/include/openssl.bak //这个有些场景不存在
	cp -rf /etc/ssh  $file_backup/ssh/ssh_$date_time.bak > /dev/null
	cp -rf /etc/pam.d/sshd.pam  $file_backup/ssh/sshd_$date_time.pam.bak > /dev/null
	cp -rf /etc/init.d/sshd  $file_backup/ssh/sshd_$date_time.bak > /dev/null
	cp -rf /usr/lib/systemd/system/sshd.service  $file_backup/ssh/sshd_$date_time.service.bak > /dev/null
}

Install_tar() {
	#下载的源码包,检查是否解压(可修改)
	#	if [ -e $file/$zlib_version.tar.gz ] && [ -e $file/$openssl_version.tar.gz ] && [ -e /$file/$openssh_version.tar.gz ];then
	#		echo -e " 下载软件源码包已存在  " "\033[32m  Please continue\033[0m"
	#	else
	#		echo -e "\033[33m 未发现本地源码包,链接检查获取中........... \033[0m "
	#	echo ""
	#	cd $file
	#	wget --no-check-certificate  $zlib_download
	#	wget --no-check-certificate  $openssl_download
	#	wget --no-check-certificate  $openssh_download
	#	echo ""
	#	fi
	#zlib
	echo -e "\033[33m 正在下载Zlib软件包...... \033[0m"
	sleep 3
	echo ""
	if [ -e $file/$zlib_version.tar.gz ];then
		echo -e " Zlib软件包已存在  " "\033[32m  Please continue\033[0m"
	else
		echo -e "\033[33m 未发现zlib本地源码包,链接检查获取中........... \033[0m "
		sleep 1
		echo ""
		cd $file
		wget --no-check-certificate  $zlib_download
		echo ""
	fi
	#openssl
	echo -e "\033[33m 正在下载Openssl软件包...... \033[0m"
	sleep 3
	echo ""
	if  [ -e $file/$openssl_version.tar.gz ];then
		echo -e " Openssl软件包已存在  " "\033[32m  Please continue\033[0m"
	else
		echo -e "\033[33m 未发现openssl本地源码包,链接检查获取中........... \033[0m "
		echo ""
		sleep 1
		cd $file
		wget --no-check-certificate  $openssl_download
		echo ""
	fi
	#openssh
	echo -e "\033[33m 正在下载Openssh软件包...... \033[0m"
	sleep 3
	echo ""
	if [ -e /$file/$openssh_version.tar.gz ];then
		echo -e " Openssh软件包已存在  " "\033[32m  Please continue\033[0m"
	else
		echo -e "\033[33m 未发现openssh本地源码包,链接检查获取中........... \033[0m "
		echo ""
		sleep 1
		cd $file
		wget --no-check-certificate  $openssh_download
	fi
}

echo ""
#安装zlib
Install_zlib() {
	echo -e "\033[33m 1.1-正在解压Zlib软件包...... \033[0m"
	sleep 3
	echo ""
	cd $file && mkdir -p $file_install && tar -xzf zlib*.tar.gz -C $file_install > /dev/null
	if [ -d $file_install/$zilb_version ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  zilb解压源码包成功" "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  zilb解压源码包失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi
	echo -e "\033[33m 1.2-正在编译安装Zlib服务.............. \033[0m"
	sleep 3
	echo ""
	cd $file_install/zlib*
	./configure --prefix=$default/$zlib_version > $file_log/zlib/zlib_configure_$date_time.txt  #> /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "\033[33m make... \033[0m"
			make > /dev/null 2>&1
		echo $?
		echo -e "\033[33m make test... \033[0m"
			make test > /dev/null 2>&1
		echo $?
		echo -e "\033[33m make install... \033[0m"
			make install > /dev/null 2>&1
		echo $?
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  编译安装压缩库失败,脚本退出中..." "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi

	if [ -e $default/$zlib_version/lib/libz.so ];then
		sed -i '/zlib/'d /etc/ld.so.conf
		echo "$default/$zlib_version/lib" >> /etc/ld.so.conf
		echo "$default/$zlib_version/lib" >> /etc/ld.so.conf.d/zlib.conf
		ldconfig -v > $file_log/zlib/zlib_ldconfig_$date_tim
		/sbin/ldconfig
	fi
}

echo ""
Install_openssl() {
	echo -e "\033[33m 2.1-正在解压Openssl...... \033[0m"
	sleep 3
	echo ""
	cd $file  &&  tar -xvzf openssl*.tar.gz -C $file_install > /dev/null
	if [ -d $file_install/$openssl_version ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  OpenSSL解压源码包成功" "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  OpenSSL解压源码包失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi
		echo ""
		echo -e "\033[33m 2.2-正在编译安装Openssl服务...... \033[0m"
		sleep 3
		echo ""
		cd $file_install/$openssl_version
		./config shared zlib --prefix=$default/$openssl_version >  $file_log/ssl/ssl_config_$date_time.txt  #> /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "\033[33m make clean... \033[0m"
			make clean > /dev/null 2>&1
		echo $?
		echo -e "\033[33m make install... \033[0m"
			make install > /dev/null 2>&1
		echo $?
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  编译安装OpenSSL失败,脚本退出中..." "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi

	mv /usr/bin/openssl /usr/bin/openssl_$date_time.bak #先备份
	mv /usr/include/openssl /usr/include/openssl_$date_time.bak #有些不存在
	if [ -e $default/$openssl_version/bin/openssl ];then
		sed -i '/openssl/'d /etc/ld.so.conf
		echo "$default/$openssl_version/lib" >> /etc/ld.so.conf
		ln -s $default/$openssl_version/bin/openssl /usr/bin/openssl
		ln -s $default/$openssl_version/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
		ln -s $default/$openssl_version/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
		ldconfig -v > $file_log/ssl/ssl_ldconfig_$date_time.txt > /dev/null 2>&1
		/sbin/ldconfig
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 编译安装OpenSSL " "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		echo -e "\033[33m 2.3-正在输出 OpenSSL 版本状态.............. \033[0m"
		sleep 3
		echo ""
		echo -e "\033[32m====================== OpenSSL veriosn =====================  \033[0m"
		echo ""
		openssl version -a
		echo ""
		echo -e "\033[32m=======================================================  \033[0m"
		sleep 2
	else
		echo ""
		echo -e "\033[33m 2.3.1-正在还原OpenSSL中...... \033[0m"
		rm -rf /usr/bin/openssl
		mv /usr/bin/openssl_$date_time.bak /usr/bin/openssl
		rm -rf /usr/include/openssl
		mv /usr/include/openssl_$date_time.bak /usr/include/openssl
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 还原成功 " "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		echo -e "\033[32m====================== OpenSSL veriosn =====================  \033[0m"
		openssl version
		echo ""
		sleep 3
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " OpenSSL软连接失败,脚本退出中..." "\033[31m  Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi
}

echo ""
Install_openssh() {
	echo -e "\033[33m 3.1-正在解压OpenSSH...... \033[0m"
	sleep 3
	echo ""
	cd $file && tar -xvzf openssh*.tar.gz -C $file_install > /dev/null
	if [ -d $file_install/$openssh_version ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  OpenSSh解压源码包成功" "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  OpenSSh解压源码包失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
	exit
	fi
	cp -rf /etc/ssh /etc/ssh_$date_time.bak #cp安装时,不会覆盖原配置
	echo ""
	echo -e "\033[33m 3.2-正在卸载OpenSSH服务...... \033[0m"
	sleep 3
	echo ""
	rpm -e --nodeps `rpm -qa | grep openssh`> /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 卸载OpenSSH服务成功" "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 2
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e "  卸载OpenSSH服务失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
	exit
	fi
	echo ""
	echo -e "\033[33m 3.3-正在编译安装OpenSSH服务...... \033[0m"
	sleep 3
	echo ""
	cd $file_install/$openssh_version
	./configure --prefix=$default/$openssh_version --sysconfdir=/etc/ssh --with-ssl-dir=$default/$openssl_version --with-zlib=$default/$zlib_version >  $file_log/ssh/ssh_configure_$date_time.txt   #> /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "\033[33m make clean... \033[0m"
			make clean > /dev/null 2>&1
		echo $?
		echo -e "\033[33m make install... \033[0m"
			make install > /dev/null 2>&1
		echo $?
	else
		echo ""
		echo -e "\033[33m 3.3.1-正在重装OpenSSH中...... \033[0m"
		yum -y install openssh openssh-clients openssh-server
		# 还原配置
		rm -rf /etc/ssh
		mv /etc/ssh_$date_time.bak /etc/ssh
		# 修改密钥权限
		chmod 600 /etc/ssh/ssh_host_rsa_key
		chmod 600 /etc/ssh/ssh_host_dsa_key
		chmod 600 /etc/ssh/ssh_host_ecdsa_key
		chmod 600 /etc/ssh/ssh_host_ed25519_key
		# 启动
		systemctl start sshd
		echo ""
		echo -e "\033[33m 输出sshd服务状态: \033[33m"
		systemctl status sshd.service
		echo ""
		echo -e " 重装openssh版本信息:  "
		echo ""
		ssh -V
		sleep 1
		echo ""
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 重装成功,请确认配置后再重启ssh! " "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 3
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 编译安装OpenSSH失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 4
		exit
	fi
		
	echo ""
	echo -e "\033[33m--------------------------------------------------------------- \033[0m"
	echo -e " 编译安装OpenSSH " "\033[32m Success\033[0m"
	echo -e "\033[33m--------------------------------------------------------------- \033[0m"
	echo ""
	sleep 2
	echo -e "\033[32m==================== OpenSSH—file veriosn =================== \033[0m"
	echo ""
	/usr/local/$openssh_version/bin/ssh -V
	echo ""
	echo -e "\033[32m======================================================= \033[0m"
	sleep 3
	echo ""
	echo -e "\033[33m 3.4-正在迁移OpenSSH配置文件...... \033[0m"
	sleep 3
	echo ""
	# 还原配置
	rm -rf /etc/ssh
	mv /etc/ssh_$date_time.bak /etc/ssh
	#迁移sshd
	if [ -f  "/etc/init.d/sshd" ];then
		mv /etc/init.d/sshd /etc/init.d/sshd_$date_time.bak
	else
		echo -e " /etc/init.d/sshd不存在 " "\033[31m Not backed up(可忽略)\033[0m"
	fi
	cp -rf $file_install/$openssh_version/contrib/redhat/sshd.init /etc/init.d/sshd;
	chmod u+x /etc/init.d/sshd;
	chkconfig --add sshd      #自启动
	chkconfig --list |grep sshd;
	chkconfig sshd on

	#备份启动脚本,不一定有
	if [ -f  "/usr/lib/systemd/system/sshd.service" ];then
		mv /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.service_bak
	else
		echo -e " sshd.service不存在" "\033[31m Not backed up(可忽略)\033[0m"
	fi
	#备份复制sshd.pam文件
	if [ -f "/etc/pam.d/sshd.pam" ];then
		mv /etc/pam.d/sshd.pam /etc/pam.d/sshd.pam_$date_time.bak 
	else
		echo -e " sshd.pam不存在" "\033[31m Not backed up(可忽略)\033[0m"
	fi
	cp -rf $file_install/$openssh_version/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam

	#还原配置ssh_config	
	# cp -rf $file_install/$openssh_version/sshd_config /etc/ssh/sshd_config
	sed -i 's/Subsystem/#Subsystem/g' /etc/ssh/sshd_config
	echo "Subsystem sftp $default/$openssh_version/libexec/sftp-server" >> /etc/ssh/sshd_config
	# sed -i 's/#PasswordAuthentication\ yes/PasswordAuthentication\ yes/g' /etc/ssh/sshd_config
	cp -rf $default/$openssh_version/sbin/sshd /usr/sbin/sshd
	cp -rf /$default/$openssh_version/bin/ssh /usr/bin/ssh
	cp -rf $default/$openssh_version/bin/ssh-keygen /usr/bin/ssh-keygen
	#grep -v "[[:space:]]*#" /etc/ssh/sshd_config  |grep "PubkeyAuthentication yes"
	# echo 'PermitRootLogin no' >> /etc/ssh/sshd_config

	# 修改秘钥的权限
	chmod 600 /etc/ssh/ssh_host_rsa_key
	chmod 600 /etc/ssh/ssh_host_dsa_key
	chmod 600 /etc/ssh/ssh_host_ecdsa_key
	chmod 600 /etc/ssh/ssh_host_ed25519_key

	#重启sshd
	service sshd start > /dev/null 2>&1
	if [ $? -eq 0 ];then
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 启动OpenSSH服务成功" "\033[32m Success\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo ""
		sleep 2
		#删除源码包(可修改)
		# rm -rf $file/*$zlib_version.tar.gz
		# rm -rf $file/*$openssl_version.tar.gz
		# rm -rf $file/*$openssh_version.tar.gz
		#rm -rf $file_install
		echo -e "\033[33m 3.5-正在输出 OpenSSH 版本...... \033[0m"
		sleep 3
		echo ""
		echo -e "\033[32m==================== OpenSSH veriosn =================== \033[0m"
		echo ""
		ssh -V
		echo ""
		echo -e "\033[32m======================================================== \033[0m"
	else
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		echo -e " 启动OpenSSH服务失败,脚本退出中......" "\033[31m Error\033[0m"
		echo -e "\033[33m--------------------------------------------------------------- \033[0m"
		sleep 4
		exit
	fi
	echo ""
}

End_install() {
	##sshd状态
	echo ""
	echo -e "\033[33m 输出sshd服务状态: \033[33m"
	sleep 2
	echo ""
	systemctl status sshd.service
	echo ""
	echo ""
	echo ""
	sleep 1
		
	echo -e "\033[33m==================== OpenSSH file =================== \033[0m"
	echo ""
	echo -e " 当前openssh版本信息:  "
	echo ""
	ssh -V
	echo ""
	echo -e " 当前openssl版本信息:  "
	echo ""
	openssl version
	echo ""
	echo -e " Openssh升级备份目录:  " 
	cd  $file_backup && pwd
	cd ~
	echo ""
	echo -e " 升级日志目录请前往:  "
	cd  $file_log && pwd
	cd ~
	echo ""
	echo -e "\033[33m======================================================= \033[0m"
}


Install_make
Install_backup
Install_tar
Install_zlib
Install_openssl
Install_openssh
End_install
  • 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
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
  • 382
  • 383
  • 384
  • 385
  • 386
  • 387
  • 388
  • 389
  • 390
  • 391
  • 392
  • 393
  • 394
  • 395
  • 396
  • 397
  • 398
  • 399
  • 400
  • 401
  • 402
  • 403
  • 404
  • 405
  • 406
  • 407
  • 408
  • 409
  • 410
  • 411
  • 412
  • 413
  • 414
  • 415
  • 416
  • 417
  • 418
  • 419
  • 420
  • 421
  • 422
  • 423
  • 424
  • 425
  • 426
  • 427
  • 428
  • 429
  • 430
  • 431
  • 432
  • 433
  • 434
  • 435
  • 436
  • 437
  • 438
  • 439
  • 440
  • 441
  • 442
  • 443
  • 444
  • 445
  • 446
  • 447
  • 448
  • 449
  • 450
  • 451
  • 452
  • 453
  • 454
  • 455
  • 456
  • 457
  • 458
  • 459
  • 460
  • 461
  • 462
  • 463
  • 464
  • 465
  • 466
  • 467
  • 468
  • 469
  • 470
  • 471
  • 472
  • 473
  • 474
  • 475
  • 476
  • 477
  • 478
  • 479
  • 480
  • 481
  • 482
  • 483
  • 484
  • 485
  • 486
  • 487
  • 488
  • 489
  • 490
  • 491
  • 492
  • 493
  • 494
  • 495
  • 496
  • 497
  • 498
  • 499
  • 500
  • 501
  • 502
  • 503
  • 504
  • 505
  • 506
  • 507
  • 508
  • 509
  • 510
  • 511
  • 512
  • 513
  • 514
  • 515
  • 516
  • 517
  • 518
  • 519
  • 520
  • 521
  • 522
  • 523
  • 524
  • 525
  • 526
  • 527
  • 528
  • 529
  • 530
  • 531
  • 532
  • 533
  • 534
  • 535
  • 536
  • 537
  • 538
  • 539
  • 540
  • 541
  • 542
  • 543
  • 544
  • 545
  • 546
  • 547
  • 548
  • 549
  • 550
  • 551
  • 552
  • 553
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/285770
推荐阅读
相关标签
  

闽ICP备14008679号