SSH asks me to go way because of ntp clock skew
Scenario
When I try to ssh to a remote server from my linux desktop, I get:
1 2 |
|
Then I realize that my shell prompt changes to [I have no name!@localhost]$
. Apparently, whoami
stops working:
1 2 |
|
Another thing I find accidentally is that if I disconnect my desktop from internet, whoami
works again. So my guess is that whoami
tries to get name from a remote server if there is internet connection. Otherwise, it falls back to use a local database which contains the correct data. My first theory is that the data on the remote server is corrupted. To figure out the remote server that whoami
talks to, I run strace
:
1 2 3 4 |
|
So whoami
talks to lsassd
daemon which then talks to Active Directory
server. Based on my first theory, it looks like the data on the Active Directory
server is corrupted. To confirm this, I run lw-find-user-by-id
:
1 2 |
|
Hmm, this means that my first theory is wrong. To confirm the clock skew, I run ntpq
:
1 2 3 4 5 |
|
It turns out that the desktop clock is off by 6 minutes. Now the question arises: why ntpd
fails to sync up the correct time with the ntp server after the clock skew happens? After googling, I find that ntpd
indeed tries to fix the clock skew but just in a slow speed (https://serverfault.com/a/608157). It takes ntpd
more than 1 week to fix 6 minutes skew.
Solution
Force ntpd
to do sync up using -g
option:
1 2 3 4 5 |
|