Run:
$ apt-get update
$ apt-get -yy install gcc mercurial libpam0g-dev git
$ git clone https://code.google.com/p/google-authenticator/
$ cd google-authenticator/libpam
$ make install
Edit /etc/ssh/sshd_config file and change the ChallengeResponseAuthentication from no to yes
edit /etc/pam.d/common-auth so it looks like
# here are the per-package modules (the "Primary" block)
auth required pam_google_authenticator.so
auth [success=1 default=ignore] pam_unix.so nullok_secure
# here's the fallback if no module succeeds
Run google-authenticator as the user you want to use two factor authentication on.
Paste the generated URL into your browser and a QRCode will be generated.
Scan the QR code with the Google Authenticator app on your iPhone.
Reboot the server and test.