1826443 Members
3977 Online
109692 Solutions
New Discussion

NTP Config Changes

 
SOLVED
Go to solution
Vipulinux
Respected Contributor

NTP Config Changes

Hello All

I want to change the the NTP server location on all my linux server's

Is there a way I can do it from a script. ( I dont want to login in each box and then edit the file and restart NTP)

Thanks
Vipul
6 REPLIES 6
Vitaly Karasik_1
Honored Contributor

Re: NTP Config Changes

You should just allow ssh/scp without password to your linux servers from some "management" linux machine, after that you can:
- distribute updated ntp.conf using scp
- run "service ntpd restart" using ssh

Rgds,
Vitaly
Vipulinux
Respected Contributor

Re: NTP Config Changes

Hi

Can i use some kind of script that will read an tst file and then ssh to each box and then ask whether i want to copy ntp conf file and if i say yes it copies. That is what I am looking for dont wanna login to 100 of server's

Thanks
Ivan Ferreira
Honored Contributor
Solution

Re: NTP Config Changes

You can create a script like this:


for IP in `seq 254`; do
echo "192.168.0.$IP: Do you want to transfer the file to this host?"
read OPTION
if [ $OPTION = yes ]; then
scp $1 192.168.0.$IP:$2
# service restart
else
echo "Skipping host 192.168.0.$IP"
fi


In this example, you will transfer a test file (first argument) to all hosts in the network 192.168.0. You need to confirm the transfer, and the location is the second argument, use it like this:

transfer_file.bash /tmp/testfile /etc

To transfer /tmp/testfile to the /etc directory. Anyway, you need to login to all hosts unless you have configured public keys without authentication.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Steven E. Protter
Exalted Contributor

Re: NTP Config Changes

Shalom,

I would make one script on one server, test it and distribute it with ssh or rsync using ssh.

Then issue a ssh hostname "service ntpd restart" from a central server.

Centralized ssh password free access needs to be in place prior to this.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Bill Thorsteinson
Honored Contributor

Re: NTP Config Changes

Changes like this are typical of a task
that you would use cfengine for. It could
do the whole distribution and restart for
you.

Failing that scp/ssh or rsync as suggested
are also appropriate.

I expect this would be your NTP server that
the address is changing for. Make sure
you don't replace its config file.

I use a standard ntp.conf file for all servers
that support the includefile directive.
The included files specifies the servers.

You will need to distribute the file to all
the clients/

If you have keys setup you can use ntpdc
to reconfigure the running clients.
Otherwise you will need to restart the
clients using ssh.

Vipulinux
Respected Contributor

Re: NTP Config Changes

Hi All

Thanks fir the info. As I need to login to every box will look at setting ssh keys and then use a script to reduce the manual task for next time.

Thanks
Vipul