Last updated on November 26, 2020 by Dan Nanni
Google Authenticator is an application which can generate time-based one-time passcode to be used for two-factor authentication. You can install Google Authenticator on Linux as a pre-built package or by building it from the source.
For those of you who don't want to build Google Authenticator, it is available as a pre-built package on several Linux distros. The pre-built package contains Google Authenticator binary and its PAM module.
$ sudo apt-get install libpam-google-authenticator
$ sudo yum install google-authenticator
First enable EPEL repository, and then run:
$ sudo yum install google-authenticator
First, install prerequisites for building Google Authenticator.
On Debian, Ubuntu or Linux Mint:
$ sudo apt-get install wget make gcc libpam0g-dev
On CentOS, Fedora or RHEL:
$ sudo yum install wget make gcc pam-devel
Then download the source code of Google Authenticator, and compile it as follows.
$ wget https://google-authenticator.googlecode.com/files/libpam-google-authenticator-1.0-source.tar.bz2 $ tar xvfvj libpam-google-authenticator-1.0-source.tar.bz2 $ cd libpam-google-authenticator-1.0 $ make
If build is successful, you will see pam_google_authenticator.so
and google-authenticator
created in the directory.
Finally, go ahead and install Google Authenticator.
$ sudo make install
For instructions on how to set up two-factor authentication for SSH logins with Google Authenticator, refer to this guideline.
1. I am getting the following error when compiling Google Authenticator.
fatal error: security/pam_appl.h: No such file or directory
To fix this problem, install the following package.
On Debian, Ubuntu or Linux Mint:
$ sudo apt-get install libpam0g-dev
On CentOS, Fedora or RHEL:
$ sudo yum install pam-devel
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean