Welcome to UltratechHost Forum, Guest. Please take the time to register if you haven't, or click

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

installing google 2 factor authentication on linux

Installing Google 2-Factor Authentication on Linux
Installing Google 2-Factor Authentication on Linux:
1. Install EPEL (Extra Packages for Enterprise Linux), choose your OS and install the rpm accordingly.
## RHEL/CentOS 7 64-Bit ##
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
# rpm -ivh epel-release-7-2.noarch.rpm
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
## RHEL/CentOS 5 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

## RHEL/CentOS 5 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm

2. You need to download Google Authenticator app that generates
2-step verification codes on your phone or desktop. Install Google Authenticator before you install anything else on your Android device/iPhone/iPad/BlackBerry/Firefox devices.
URL: https://support.google.com/accounts/answer/1066447?hl=en

3. Installing Google Authenticator & ntp
[root@server ~]# yum install google-authenticator ntp –y

4. Now start the ntp deamon:
[root@server ~]# service ntp start

5. Configure Google Authenticator:
Quote:[root@server ~]# google-authenticator
Your new secret key is: 4JRADVVN2SAGFTTZ
Your verification code is 381540
Your emergency scratch codes are:
Do you want me to update your "~/.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

6. Now Open Google Authenticator on your Android Phone:
• Click on Setup Account
• Click on Enter Provided Key
• Give Account Name: Server
• Give your secret key : Here its 4JRADVVN2SAGFTTZ
• Make it as time based

7. Using vi editor add auth required pam_google_authenticator.so
to /etc/pam.d/sshd file which looks like:
[root@server ~]# vi /etc/pam.d/sshd
auth required pam_google_authenticator.so
auth required pam_sepermit.so
auth include password-auth

8. Using vi editor change ChallengeResponseAuthentication no to
ChallengeResponseAuthentication yes in /etc/ssh/sshd_config
[root@server ~]# vi /etc/ssh/sshd_config

9. Now restart your sshd deamon:
[root@server ~]# service sshd restart
[root@server ~]# systemctl restart sshd.service

Now we have configured everything logout and login you will have it
login as:
Using keyboard-interactive authentication.
Verification code:
Using keyboard-interactive authentication.

Dinesh Kumar Mohanty
Ultra Web Solutions®
Bhubaneswar, Odisha, India.

UltratechHost - Your One Stop Offshore & Onshore Hosting Provider
Server Locations : Netherlands, Germany, Russia, Singapore & USA
Service Offers: Shared hosting | Reseller hosting | Cloud server | Dedicated server | VPS Hosting

Forum Jump:

Users browsing this thread: 1 Guest(s)