Using pam-google-authenticator does not depends on Google, they just wrote widely available apps and a PAM module[0] that implement HOTP[1] and TOTP[2]. Basically, you have a seed and a counter that you hash together. When adding a device, the seed and counter are synced with the device. When logging in, the server generates the proper code, then verifies it got that code. The major difference between the two algorithms is that TOTP uses time as its counter, while HOTP uses a manually increased counter.
[0] http://code.google.com/p/google-authenticator/
[1] http://en.wikipedia.org/wiki/HOTP
[2] http://en.wikipedia.org/wiki/Time-based_One-time_Password_Al...