Filed under Computer/Linux
1. download source from

2. extract
    tar jxvf libpam-google-authenticator-xxx.tar.bz2

3. compile
    cd libpam-google-authenticator-xx

4. copy requirement files
   cp google-authenticator /usr/local/bin
   cp /lib64/security

5. configuration to ssh
   vi /etc/pam.d/sshd
   auth       required

   vi /etc/ssh/sshd_config
   ChallengeResponseAuthentication yes

6. restart sshd
   /etc/init.d/sshd restart

7. create QR code to my account
Do you want authentication tokens to be time-based (y/n) y|0&cht=qr&chl=otpauth~~~
Your new secret key is: ~~~
Your verification code is ~~~
Your emergency scratch codes are:

Do you want me to update your "/Users/kage/.google_authenticator" file (y/n) y

Do you want to disallow multiple uses of the same authentication
token? This restricts you to one login about every 30s, but it increases
your chances to notice or even prevent man-in-the-middle attacks (y/n) y

By default, tokens are good for 30 seconds and in order to compensate for
possible time-skew between the client and the server, we allow an extra
token before and after the current time. If you experience problems with poor
time synchronization, you can increase the window from its default
size of 1:30min to about 4min. Do you want to do so (y/n) y

If the computer that you are logging into isn't hardened against brute-force
login attempts, you can enable rate-limiting for the authentication module.
By default, this limits attackers to no more than 3 login attempts every 30s.
Do you want to enable rate-limiting (y/n) y  

8. download "Authy" App from App Store to your iPhone

9. click "+Add Authenticator Account" and click "Scan QR Code"
   and scan before QR code.

   * If you lost before QR code on the console screen or disappear QR code in your screen then you can copy "|0&cht=qr&chl=otpauth~~~" and paste to your web browser then you can see the QR code.

10. login with ssh to your system like this way.
$ ssh <id>@<your host>
Verification code: xxxxxx
Password: xxxxxx
2014/02/12 02:07 2014/02/12 02:07