Sync time on WSL with Windows

how-to wsl
21 Jun 2023

Recently while working on Azure CLI on WSL, I started getting below error.

The ID token is not yet valid. Make sure your computer's time and time zone are both correct

I checked the time on my WSL (Ubuntu distro) using date, and it was not in sync with the Windows time. This resulted in Azure CLI authentication token to be invalid.

To fix this, I had to sync the time on WSL with Windows. To do that run the below command on WSL.

$ sudo hwclock -s