#其他#数据库#前端#php#java

安装 net-tools

文件名:net-toolsInstall.sh

yum -y install net-tools

安装vim

文件名:vimInstall.sh

#!bin/bashyum  install vim-enhanced

安装wget

文件名:wgetInstall.sh

#!bin/bashyum -y install wget

安装 jdk8

文件名:jdk8Install.sh

#!bin/bash# 创建文件夹,当存在/usr/local/java文件夹时删除重建if [ ! -d '/usr/local/java']   then    mkdir /usr/local/javaelse    rm -rf /usr/local/java    mkdir /usr/local/javaficd  /usr/local/java# 下载jdk1.8压缩包wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http://www.oracle.com/; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"  tar -zxvf jdk-8u141-linux-x64.tar.gz  # 解压jdk压缩包mv jdk1.8.0_141/ jdk8   # 将解压的文件夹重命名vim /etc/profile # 配置环境变量    ##echo "export JAVA_HOME=/usr/local/java/jdk8">>/etc/profile#echo "export PATH=/usr/local/java/jdk8/bin:$PATH">>/etc/profile#echo "export CLASSPATH=.:/usr/local/java/jdk8/lib/dt.jar:/usr/local/java/jdk8/lib/tools.jar/usr/local/java/jdk8/jre/lib/rt.jar">>/etc/profile  source /etc/profile  # 重新加载配置
java -version #测试安装结果

注意:

  1. 如果最后没有打印出jdk版本的话vim /etc/profile看看其中对jdk环境变量的配置是否已经配置成功了、

  2. 如果文件末尾没有以下类容,则加上。(如果配多了请删除)

export JAVA_HOME=/usr/local/java/jdk8export PATH=/usr/local/java/jdk8/bin:$PATHexport CLASSPATH=.:/usr/local/java/jdk8/lib/dt.jar:/usr/local/java/jdk8/lib/tools.jar/usr/local/java/jdk8/jre/lib/rt.jar

安装 Tomcat9.0.64

文件名:tomcatInstall.sh

#!bin/bash# 创建文件夹,当存在/usr/local/tomcat文件夹时删除重建if [ ! -d '/usr/local/tomcat']   then    mkdir /usr/local/tomcatelse    rm -rf /usr/local/tomcat    mkdir /usr/local/tomcatficd /usr/local/tomcat# 下载tomcat压缩包,如果下载不了的话就取官网拿这个连接替换wget https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-9/v9.0.64/bin/apache-tomcat-9.0.64.tar.gztar -zxvf apache-tomcat-9.0.64.tar.gz  # 解压压缩包mv apache-tomcat-9.0.64 tomcat  #将解压的文件夹重命名cd /usr/local/tomcat/tomcat/bin/ # 进入tomcat的bin目录  # 向catalina.sh文件末尾写入配置echo "JAVA_OPTS=\"-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m\"">>catalina.shecho "export TOMCAT_HOME=/usr/local/tomcat/tomcat">>catalina.shecho "export CATALINA_HOME=/usr/local/tomcat/tomcat">>catalina.shecho "export JRE_HOME=/usr/local/java/jdk8/jre">>catalina.shecho "export JAVA_HOME=/usr/local/java/jdk8">>catalina.sh
cd /usr/local/tomcat/tomcat/bin
sh startup.sh
jps
ps -ef|grep java

安装nginx1.7

文件名:nginxInstall.sh

#!/bin/bashif [ ! -d '/usr/local/nginx' ]        then                mkdir /usr/local/nginxelse        rm -rf /usr/local/nginx        mkdir /usr/local/nginxfi
cd /usr/local/nginx
yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel
# 2022-10-18 获取最新版本http://nginx.org/download/nginx-1.23.1.tar.gz 19-Jul-2022 14:30 wget http://nginx.org/download/nginx-1.7.0.tar.gz
tar -zxvf nginx-1.7.0.tar.gz
mv nginx-1.7.0 nginx1.7.0
cd /usr/local/nginx/nginx1.7.0/
./configure --prefix=/usr/local/nginx
make && make install
/usr/local/nginx/nginx1.7.0/sbin/nginx -s reload
firewall-cmd --state
systemctl start firewalld.service

firewall-cmd --add-port=80/tcp
cd /usr/local/nginx/sbin
./nginx./nginx -s reload
./nginx -v

nginx 1.7 平滑升级

文件名称:updateNginx.sh

#/bin/bashecho "开始平滑升级nginx,请将最新版本的nginx安装包上传到与旧版本nginx安装目录同级路径下~"
read -ep "请输入旧版本nginx安装路径:" oldNginxPath
if [ -z ${oldNginxPath} ]then echo '未输入旧版本nginx安装路径,退出程序' exit 1001fi
echo "旧版本的nginx版本号为:" cd ${oldNginxPath}/sbin/./nginx -v
if [ ! -d ${oldNginxPath} ]then echo ${oldNginxPath} '不是文件夹,退出程序' exit 1001fi
read -ep "请输入新版本nginx安装包所在的路径:" newNginxZipPathif [ -z ${newNginxZipPath} ]then echo '未输入新版本nginx安装包所在的路径,退出程序' exit 1001fiif [ -d ${newNginxZipPath} ]then echo ${newNginxZipPath} '非nginx压缩包,退出程序' exit 1001fi
cd ${oldNginxPath}cd ../
echo "开始备份旧版本的nginx..."bakNum=$(date -d "" +%Y%m%d)cp -r ${oldNginxPath} ${oldNginxPath}${bakNum}echo " 备份旧版本的nginx完成,备份地址:"${oldNginxPath}${bakNum}
echo '开始解压'${newNginxZipPath}'压缩包:'tar -zxf ${newNginxZipPath}echo '压缩包解压完毕,nginx相关的文件夹如下:'
ls ./nginx-*
read -ep "请输入解压后的nginx文件夹名称:" newNginxDirNameif [ -z ${newNginxDirName} ]then echo '未输入解压后的nginx文件夹名称,退出程序' exit 1001fi
cd ./${newNginxDirName}
./configure --prefix=${oldNginxPath}

make
mv ${oldNginxPath}/sbin/nginx ${oldNginxPath}/sbin/nginx_old
cp ./objs/nginx ${oldNginxPath}/sbin/
${oldNginxPath}/sbin/nginx -t
make upgrade
echo "============================================================="echo "异常示例:"echo "/usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulkill -USR2 `cat ..../nginx.pid`sleep 1test -f ..../nginx.pid.oldbinkill -QUIT `cat ..../nginx.pid.oldbin`"
read -ep "请确认是否出现以下异常?y:出现,n:未出现:" iserrif [ ${iserr} != 'y' ]then echo '升级结束' exit 1001fi
echo "nginx.pid 文件所在如下:"find / -name nginx.pid
read -ep "请输入旧版本nginx的nginx.pid路径:" oldNginxPidPathif [ -z ${oldNginxPidPath} ]then echo '未输入旧版本nginx的nginx.pid路径,退出' exit 1001fi
echo "nginx.pid.oldbin 文件所在如下:"find / -name nginx.pid.oldbinread -ep "请输入旧版本nginx的nginx.pid.oldbin路径:" oldNginxPidOldBinPathif [ -z ${oldNginxPidOldBinPath} ]then echo '未输入旧版本nginx的nginx.pid.oldbin路径,退出' exit 1001fi
kill -USR2 `cat ${oldNginxPidPath}`kill -QUIT `cat ${oldNginxPidOldBinPath}`

echo "旧版本的nginx平滑升级后的版本号为:" cd ${oldNginxPath}/sbin/./nginx -v

安装redis

文件名称:redisInstaill.sh

#!/bin/bashyum install gcc-c++ -yif [ ! -d '/usr/local/redis' ]        then                mkdir /usr/local/rediselse        rm -rf /usr/local/redis        mkdir /usr/local/redisfi
cd /usr/local/redis
wget https://download.redis.io/releases/redis-6.2.4.tar.gz
tar xzf redis-6.2.4.tar.gz
cd redis-6.2.4
make
cd src
./redis-server &
./redis-cli

防火墙开放指定端口

文件名:openPortOnFirewall.sh

#!/bin/bashread -ep " please input port: " portif [ -z ${port} ]then        #port is empty        echo "port is empty ! please input port!"        exit 1001fisystemctl start firewalld.servicefirewall-cmd --state  #查看防火墙firewall运行状态firewall-cmd --add-port=${port}/tcpfirewall-cmd --list-all

IP地址显示

当使用IP addr命令时未显示出IP地址。
文件名:showIP.sh

#!/bin/bashcd /etc/sysconfig/network-scripts/# vi ifcfg-ens33
# 替换ifcfg-ens33 ONBOOT=no 为 ONBOOT=yessed -i "/^ONBOOT=/s/no/yes/" ifcfg-ens33
service network restartip addr

安装docker

文件名dockerInstall.sh

#!/bin/bashsudo yum remove docker \                  docker-client \                  docker-client-latest \                  docker-common \                  docker-latest \                  docker-latest-logrotate \                  docker-logrotate \                  docker-engine
sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
yum list docker-ce --showduplicates | sort -r
# 注意此处的版本号 20.10.8 可以根据自己需要进行修改。当脚本执行到 上一句 时,界面会列出docker版本,选择对应的版本号修改即可。如下图所示sudo yum install docker-ce-20.10.8 docker-ce-cli-20.10.8 containerd.io
sudo systemctl start docker
docker images

安装RabbitMq

安装RabbitMq之前需要安装erlang。对用的版本如下:
erlang:erlang-21.3-1.el7.x86_64.rpm
RabbitMq:rabbitmq-server-3.8.8-1.el7.noarch.rpm

安装包下载:点击下载

安装脚本:installRabbitMq.sh

#!/bin/bashrpm -ivh /usr/local/sofeware/rabbitmq3.8.8/installPage/erlang-21.3-1.el7.x86_64.rpm
yum install socat -y
rpm -ivh /usr/local/sofeware/rabbitmq3.8.8/installPage/rabbitmq-server-3.8.8-1.el7.noarch.rpm
# rabbitmq 开机自启chkconfig rabbitmq-server on
# rabbitmq 关闭/sbin/service rabbitmq-server stop
# rabbitmq 查看运行状态/sbin/service rabbitmq-server status
# rabbitmq 自启浏览器端管理界面rabbitmq-plugins enable rabbitmq_management
# 开启管理界面的端口firewall-cmd --add-port=15672/tcp
# 开启访问的端口firewall-cmd --add-port=5672/tcp
# 查看已经存在的rabbitmq 用户 rabbitmqctl list_users
# 创建登录管理界面的用户,身份授权为管理员# 账号:root# 密码:rootrabbitmqctl add_user root root
# 设置root用户的角色 为 administratorrabbitmqctl set_user_tags root administrator
# 给 root 分配权限rabbitmqctl set_permissions -p "/" root ".*" ".*" ".*"
# 运行rabbitMq/sbin/service rabbitmq-server start
/sbin/service rabbitmq-server status

看到如下下所示说明安装并且启动成功。
安装路径在:/usr/lib/rabbitmq/lib/rabbitmq_server-3.8.8

回到物理机在浏览器上输入:虚拟机网络ip地址:15672
即可访问到网页管理端的登录界面。如下:

账号密码在shell脚本中有,属于自定义的。
账号:root
密码:root

安装延时队列插件

插件名称:rabbitmq_delayed_message_exchange-3.8.0.ez
下载后将此插件复制到rabbitmq的安装路径的plugins 文件夹下。
即:/usr/lib/rabbitmq/lib/rabbitmq_server-3.8.8/plugins/

注意:一般的延迟队列中,延迟的处理是在队列中,队列中有 ttl 的概念。但此插件是在交换机中进行延迟处理。

执行命令:

rabbitmq-plugins enable rabbitmq_delayed_message_exchange

重启mq

systemctl restart rabbitmq-server

验证插件是否安装成功:
进入浏览器的管理端
进入交换机界面,添加交换机界面中有如下插件选项说明安装成功。

安装mysql 8

脚本名称 :vim mysqlInstall.sh
到MySQL官网下载安装包,此处我下载的版本安装包为:mysql-8.0.28-el7-x86_64.tar.gz
下载后把安装包上传到服务器的 /usr/local/ 下

脚本如下 :

#!/bin/bashecho "请将mysql的安装包放在 /usr/local/ 目录下"read -ep " 已放入请输入 yes : " isYesif [ "yes" == ${isYes} ]then  if [ ${isYes} == "yes" ]   then    read -ep " 请输入压缩包名称 : " name    if [ -z ${name} ]    then          echo "未输入。退出!"            exit 1001    fi    cd /usr/local/    tar -zxvf ${name}    echo " 以下为当前目录下MySQL相关的文件夹 "    ls |grep mysql         read -ep  "请输入解压后的文件夹名称:"  dirName    if [ -z ${dirName} ]     then              echo "未输入解压后的文件夹名称。退出!"           exit 1001    fi
mv ./${dirName} ./mysql mv ./${name} ./mysql/ echo "已经将文件夹:"${dirName}"名称修改为mysql,并将压缩包"${name}"放入该文件夹下,如下" cd ./mysql ll echo "正在创建mysql用户和用户组,并给当前文件夹授权" groupadd mysql useradd -r -g mysql mysql chown -R mysql:mysql ./ echo "即将开始初始化mysql,请注意日志中打印的初始默认密码,并将密码复制保存。格式:root@localhost: 初始化密码" read -ep "继续输入yes:" startInitMysqlOption if [ "yes" == ${startInitMysqlOption} ] then echo "开始初始化:" bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data systemctl start firewalld.service firewall-cmd --add-port=3306/tcp firewall-cmd --list-all echo "初始化完成" cd /etc/ ls | grep my.cnf read -ep "以上是否列出:my.cnf 和 my.cnf.d ? 存在输入:yes" ishaveMycnf if [ "yes" == ${ishaveMycnf} ] then mv ./my.cnf ./my_bak.cnf touch my.cnf echo "[mysqld]" >> my.cnf echo "basedir=/usr/local/mysql" >> my.cnf echo "datadir=/usr/local/mysql/data" >> my.cnf echo "port=3306" >> my.cnf echo "socket=/tmp/mysql.sock" >> my.cnf echo "pid-file=/usr/local/mysql/$hostname.pid" >> my.cnf echo "sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES" >> my.cnf
# 最后my.cnf的配置如下 # [mysqld] # basedir=/usr/local/mysql # datadir=/usr/local/mysql/data # port=3306 # socket=/tmp/mysql.sock # pid-file=/usr/local/mysql/$hostname.pid # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
echo "export MYSQL_HOME" >> /etc/profile echo "MYSQL_HOME=/usr/local/mysql" >> /etc/profile echo "export PATH=$PATH:$MYSQL_HOME/lib:$MYSQL_HOME/bin" >> /etc/profile read -ep "MySQL是否设置开机自动启动?yes 自启 ,no 不自启:" autoStart if [ "yes" == ${autoStart} ] then cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql chkconfig --add mysql chkconfig --list fi
# 启动mysql 重启命令:service mysql restart service mysql start source /etc/profile read -ep "是否进入MySQL操作?yes进入,no不进入" enterMysql if [ "yes" == ${enterMysql} ] then echo "请输入初始化时复制的密码进行登录" mysql -uroot -p else echo "结束退出" exit 1001; fi else echo "未确认my.cnf是否存在,退出!" exit 1001 fi else echo "未确认,退出!" exit 1001 fi else echo "退出!" exit 1001 fielse echo "未确认!" exit 1001fi

进入mysql的操作界面后用以下命令修改密码

alter user  'root'@'localhost' identified by '新设置的密码';# 例如alter user  'root'@'localhost' identified by 'root';

修改密码后使用命令退出mysql重新进入

exit;

重新登录musql后测试是否能查出数据库

show databases;

需要使mysql界面管理工具访问操作数据库,在进入mysql操作界面后使用以下命令即可:

create user root@'%' identified by 'root'; grant all privileges on *.* to root@'%' with grant option;

多台服务器之间文件挂载

准备三台服务器
192.168.83.155 :存放文件的服务器,被访问端
192.168.83.151:访问端,挂载指定目录到155上
192.168.83.152:访问端,挂载指定目录到155上

创建脚本setMount.sh

#!/bin/bash/read -ep '请确认当前该机器是否是用于放文件(是:y  否:n):' typesif [ 'y' == ${types} ] then  yum install nfs-utils -y
notPath=0
read -ep '请输入用于共享的文件目录,不输入则默认使用 /mnt目录共享:' path if [ -z ${path} ] then notPath=1 fi read -ep '* 请输入可操作该目录的其他ip:' ipaddress if [ -z ${ipaddress} ] then echo '未设置ip' exit 1001 fi
echo '操作该目录的ip可分配的权限如下:' echo 'ro 该主机对该共享目录有只读权限' echo 'rw 该主机对该共享目录有读写权限' echo 'root_squash 客户机用root用户访问该共享文件夹时,将root用户映射成匿名用户' echo 'no_root_squash 客户机用root访问该共享文件夹时,不映射root用户' echo 'all_squash 客户机上的任何用户访问该共享目录时都映射成匿名用户(nfsnobody)' echo 'no_all_squash 与all_squash取反(默认设置)' echo 'anonuid=XXX 将客户机上的用户映射成指定的本地用户ID的用户(UID=xxx)' echo 'anongid=XXX 将客户机上的用户映射成属于指定的本地用户组ID (GID=xxx)' echo 'sync 资料同步写入到内存与硬盘中,效率低,但可以保证数据的一致性' echo 'async 资料会先暂存于内存中,而非直接写入硬盘' echo 'insecure 允许从这台机器过来的非授权访问' echo 'subtree_check 如果共享/usr/bin之类的子目录时,强制NFS检查父目录的权限(默认)' echo 'no_subtree_check 和上面相对,不检查父目录权限' echo 'wdelay 检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率(默认设置)' echo 'no_wdelay 如果多个用户要写入NFS目录,则立即写入,当使用async时,无需此设置。若有写操作则立即执行,应与sync配合使用' echo 'hide 在NFS共享目录中不共享其子目录' echo 'no_hide 共享NFS目录的子目录' echo 'secure NFS通过1024以下的安全TCP/IP端口发送' echo 'insecure NFS通过1024以上的端口发送'
echo '请根据以上列出的权限,给操作IP分配权限,分配格式如下:(权限1,权限2,权限3,...),不分配权限时,自动分配(rw,sync,no_root_squash,no_subtree_check) 权限!' read -ep '* 请输入权限:' setAuth if [ -z ${setAuth} ] then echo '未设置权限,使用默认(rw,sync,no_root_squash,no_subtree_check)' setAuth='(rw,sync,no_root_squash,no_subtree_check)' fi
if [ ${notPath} -eq 0 ] then echo "配置:${path} ${ipaddress}${setAuth}" echo "${path} ${ipaddress}${setAuth}" >> /etc/exports else echo "配置:/mnt ${ipaddress}${setAuth}" echo "/mnt ${ipaddress}${setAuth}" >> /etc/exports fi exportfs -rv echo '' echo '挂载配置/etc/exports如下:' cat /etc/exports echo '若配置修改,请执行命令:exportfs -rv 刷新配置'elif [ 'n' == ${types} ]then yum install nfs-utils -y notPaht=0 read -ep '请输入要挂载的目录,不输入默认/mnt ' client_path if [ -z ${client_path} ] then notPath=1 fi read -ep '请输入挂载主机的ip' master_ip if [ -z ${master_ip}] then echo '未输入主机ip' exit 1001 fi
echo "${master_ip} 可挂载的目录如下:" showmount -e ${master_ip} echo '' read -ep "请输入可挂载的目录" catsetPath if [ -z ${catsetPath} ] then echo '未输入目录' exit 1001 fi if [ 0 -eq ${notPath} ] then mount -t nfs ${master_ip}:${catsetPath} ${client_path} -o nolock
echo "${master_ip}:${catsetPath} ${client_path} nfs defaults 1 1" >> /etc/fstab else mount -t nfs ${master_ip}:${catsetPath} /mnt -o nolock echo "${master_ip}:${catsetPath} /mnt nfs defaults 1 1" >> /etc/fstab
fi echo "查看挂载结果:" mount --verbose echo '查看/etc/fstab 配置:' cat /etc/fstabelse echo '输入错误' exit 1001fi


服务器时间校准,业务服务器同步时间服务器

建脚本: timeCalibration.sh

#!/bin/bash/# 安装ntpsudo yum -y install ntp# 将服务器的时区设置为上海timedatectl set-timezone Asia/Shanghai
read -ep '是否使用网络上的时间校准服务器【服务器地址:pool.ntp.org】?(是:y 否:n):' typesif [ 'y' == ${types} ] then ntpdate pool.ntp.org echo "系统当前时间:" date "+%Y-%m-%d %H:%M:%S"else read -ep '请输入校准时间服务器的IP地址:' timeIp if [ -z ${timeIp}] then echo '未输入校准时间服务器的IP地址' exit 1001 fi ntpdate ${timeIp} echo "系统当前时间:" date "+%Y-%m-%d %H:%M:%S"fi


查询系统详细信息

创建脚本文件:systemInfo.sh

#!/bin/bashecho "查询IP地址信息:"ip addr show
echo ""
echo "查询MAC地址:"ip link show
echo ""

echo "内存总大小:"free -h
echo ""
echo "磁盘总大小:"df -h --total
echo ""echo "cpu信息:"lscpu
echo ""echo "操作系统信息:"cat /proc/version

更新openssh

脚本名称:updateOpenSSH.sh
准备工作:

  1. 使用root账号登录,并将openssh-9.4p1.tar.gz上传到/root下

  2. 将此脚本上传到/root下运行即可

#!/usr/bin/
now=`date "+%Y%m%d%H%M%S"`echo "openssh当前版本信息如下:"ssh -Vecho ""echo ""
if [ ${USER} != 'root' ]then echo "非root用户,退出脚本" exit 1001fi
if [ ! -e "/root/openssh-9.4p1.tar.gz" ]then echo "未上传 openssh-9.4p1.tar.gz 安装包,退出" echo "请将【openssh-9.4p1.tar.gz】安装包上传到/root目录下" exit 1001fi

echo "开始检查gcc环境"gcc --versionread -ep "是否存在gcc版本信息?【y.存在 n.不存在】" ishavegccif [ 'y' != "${ishavegcc}" ]then echo "安装gcc:yum -y install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel" yum -y install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel echo "不存在gcc信息,请安装gcc环境,退出" exit 1001fi
echo "开始检查openssl环境"openssl versionread -ep "openssl版本是否>=1.1.1?【y.是 n.否】" versionsslif [ 'y' != "${versionssl}" ]then echo "openssl版本过低,请升级,退出" exit 1001fi
yum install -y openssl-devel
if [ ! -d /usr/local/openssh ]then echo "开始创建openssh新的安装目录: /usr/local/openssh" mkdir -p /usr/local/opensshfi
echo "开始备份/etc/下的ssh文件"echo "备份前文件如下:"ls -l /etc | grep sshecho "备份后文件如下:"mv /etc/ssh{,.bak_`date "+%Y%m%d%H%M%S"`}ls -l /etc | grep sshecho "/etc/下的ssh文件备份完成"echo ""
cd /rootecho "开始解压openssh-9.4p1.tar.gz安装包"tar -zxvf openssh-9.4p1.tar.gzpwdecho ""
echo "进入解压后的文件夹/root/openssh-9.4p1 中"cd openssh-9.4p1pwdecho ""
echo "开始进行环境配置"./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/include --with-ssl-dir=/usr/local/lib64 --with-zlib --with-md5-passwords --with-pamecho "环境配置完成"echo ""
echo "开始编译"makeecho "编译完成"echo ""
echo "开始编译安装"make installecho "编译安装完成"echo ""
echo "开始修改ssh的配置文件:/etc/ssh/sshd_config文件"echo "/etc/ssh/sshd_config配置文件维修改前:"cat /etc/ssh/sshd_config | grep -v "#" | grep -v "^$"echo ""echo "/etc/ssh/sshd_config配置文件维修改后:"echo "UseDNS no" >> /etc/ssh/sshd_configecho 'PermitRootLogin yes' >> /etc/ssh/sshd_configecho 'PubkeyAuthentication yes' >> /etc/ssh/sshd_configecho 'PasswordAuthentication yes' >> /etc/ssh/sshd_configecho "X11Forwarding yes" >> /etc/ssh/sshd_configecho "X11UseLocalhost no" >> /etc/ssh/sshd_configecho "XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_configecho "配置文件修改完成,修改后的配置文件如下:"cat /etc/ssh/sshd_config | grep -v "#" | grep -v "^$"echo ""
echo "开始备份原有的sshd二进制文件:"echo "备份前/usr/sbin 文件如下:"ls -l /usr/sbin | grep sshdecho "备份后/usr/sbin 文件如下:"mv /usr/sbin/sshd{,.bak_`date "+%Y%m%d%H%M%S"`}ls -l /usr/sbin | grep sshdecho ""echo "备份前/usr/bin 文件如下:"ls -l /usr/bin | grep sshecho "备份后/usr/bin 文件如下:"mv /usr/bin/ssh{,.bak_`date "+%Y%m%d%H%M%S"`}mv /usr/bin/ssh-keygen{,.bak_`date "+%Y%m%d%H%M%S"`}ls -l /usr/bin | grep sshecho "备份sshd二进制文件完成"echo ""
echo "开始创建sshd二进制文件软连接:"ln -s /usr/local/openssh/bin/ssh /usr/bin/sshecho "/usr/local/openssh/bin/ssh ----> /usr/bin/ssh"ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygenecho "/usr/local/openssh/bin/ssh-keygen ----> /usr/bin/ssh-keygen"ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshdecho "/usr/local/openssh/sbin/sshd ----> /usr/sbin/sshd"echo "sshd二进制文件软连接创建完成"
echo "openssh 更新完成,当前版本信息如下:"ssh -V
echo "开始重启ssh"service sshd restart


















阅读原文

版权声明:本站部分内容由互联网用户自发贡献,文章观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请拨打网站电话或发送邮件至1330763388@qq.com 反馈举报,一经查实,本站将立刻删除。

文章标题:centerOs7安装相关的应用脚本发布于2024-01-16 22:30:29

相关推荐