diff --git a/security.sh b/security.sh index abd67ce..64f072e 100644 --- a/security.sh +++ b/security.sh @@ -7,7 +7,7 @@ read -p "修改SSH端口:" sshport if [ "$myhostname" != '' ] then sudo hostnamectl set-hostname ${myhostname} -if [ "$sshport" != '' ] +elif [ "$sshport" != '' && "$myhostname" != '' ] then #删除SSH端口 sed -i '/^#Port/'d /etc/ssh/sshd_config diff --git a/synctime.sh b/synctime.sh new file mode 100644 index 0000000..9451bfb --- /dev/null +++ b/synctime.sh @@ -0,0 +1,18 @@ +#!/bin/bash +##### CentOS一键同步时间 ##### +##### Author:xiaoz.me ##### +##### Update:2018-01-19 ##### + +#放行端口 +sed -i "/udp -j DROP/i\-A OUTPUT -p udp -m udp --dport 123 -j ACCEPT" /etc/sysconfig/iptables +service iptables restart +#同步时间 +ntpdate -u pool.ntp.org + +ntpd=(`which ntpdate`) + +#定时任务 +echo "*/20 * * * * ${ntpd} pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root +service crond reload + +echo "同步成功,当前时间:" date \ No newline at end of file