Browse Source

update

master
xiaoz 7 years ago
parent
commit
574da6c1ec
  1. 2
      security.sh
  2. 18
      synctime.sh

2
security.sh

@ -7,7 +7,7 @@ read -p "修改SSH端口:" sshport @@ -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

18
synctime.sh

@ -0,0 +1,18 @@ @@ -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
Loading…
Cancel
Save