Synchronize clock between hosts with SSH
About 1 min read
NTP is very handy for server clock synchronisation, but it can be cumbersome to deploy.
Sometimes you just need to do a one-shot clock synchronisation, so you use
the standard date
command. But there isn't a flag to easily copy a
setting to another.
From a remote host
Quite easy :
# date `ssh remoteuser@remotehost date +%m%d%H%M%Y.%S`
To a remote host
It's also very easy[1] :
# ssh root@remotehost date `date +%m%d%H%M%Y.%S`
Notes
[1] Yes, I do know that logging remotely as root is a security pitfall...