NTP is a fantastic protocol, but there are cases where you don't want to have another daemon running on a server. This script connects from machine A to machine B using SSH, reads the time from B and applies it to A.


# fetch time from machine B
time=`ssh user@b.domain.com -p522 "date +'%m%d%H%M%Y'"`
# apply date to local machine (A)
echo "Setting time to "$time
date $time