#!/bin/sh #因为现在大多都用的是centos7了所以6就没怎么写
#其它系统脑补 #优化命令提示符PS1,添加颜色 release=`cat /etc/redhat-release | awk -F'[ |.]' '{print $4}'` echo "PS1='[[e[32;1m]u[e[0m]@[e[33;1m]h[e[0m] [e[34;1m]W[e[0m]]$ '" >>/etc/bashrc #优化yum下载源 if [ `cat /etc/redhat-release | awk '{print $1}'` == 'CentOS' ];then curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo yum makecache else echo '这不是CentOS添加其它系统的软件仓库' && exit 1 fi #安装常用工具软件 yum install -y vim tree nc nmap dos2unix wget lrzsz bash-completion net-tools #关闭seLinux sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config #关闭并且禁用firewalld 或者iptables if [ $release == 7 ];then systemctl stop firewalld systemctl disable firewalld elif [ $release == 6 ];then sevice iptables stop chkconfig iptables off fi #设置时区 if [ $release == 7 ];then timedatectl set-timezone Asia/Shanghai elif [ $release == 6 ];then
echo '手动修改/etc/sysconfig/clock' fi #安装时间服务 if [ $release == 7 ];then yum install -y chrony && systemctl start chronyd timedatectl set-ntp 1 && timedatectl status elif [ $release == 6 ];then yum install -y ntp service ntpd start chkconfig ntpd on else echo "不存的版本,退出" && exit 3 fi read -p "输入你的主机名称:" name echo "你的主机名称是 $name" if [ $release == 7 ];then hostnamectl set-hostname $name elif [ $release == 6 ];then echo "HOSTNAME=$name" >> /etc/sysconfig/network fi
grep 'GSSAPIAuthentication' /etc/ssh/sshd_config
if [ `echo $?` == 0 ];then
sed -i 's@GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config
fi
sed -i 's@UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config
if [ `echo $?` != 0 ];then
sed -i 's@#UseDNS yes@UseDNS no@g' /etc/ssh/sshd_config
fi