Configure SSH dual authentication for Linux

Source: Internet
Author: User
Tags ssh server ssh config ssh config file

Background: Two-factor authentication (abbreviated as: 2FA, hereinafter referred to as 2FA), where it is the second re-authentication of SSH. 2FA refers to a method of authenticating a user with both a password and a biometric symbol such as a credit card, SMS phone, token, or fingerprint. Through two different authentication procedures, can reduce the risk of password leakage, greatly improve the security of Linux system!

First, pre-configuration preparation

  1, to prepare a running OpenSSH service Linux terminal.

2, an Android mobile phone.

Second, install Google authenticator on Linux

  1. Install Google Identity authenticator on Ubuntu:

$ sudo apt-get install libpam-google-authenticator-y

  

  2. Install Google identity authenticator on CentOS

#安装EPEL软件库 $ sudo yum install epel-release-y# installation google-authenticator$ sudo yum install-y google-authenticator

  

  3. Running Google authenticator on a Linux host

$ google-authenticator

  Google authenticator asks questions, always answer Y. The emergency backup verification code in the figure (shown in the figure: emergency scratch Codes) can resume access if you lose your bundled Android device. So, be sure to save the emergency backup verification code well!

Third, for the SSH server with Google Authenticator

 1. Modify the PAM configuration file

$ sudo vim/etc/pam.d/sshd# Disallow non-root logins when/etc/nologin exists.account    required     pam_nologin.so# Add this line auth       required     pam_google_authenticator.so

  

  2. Enable challengeresponseauthentication in SSH config file

$ sudo vim/etc/ssh/sshd_configchallengeresponseauthentication      Yes

  

  3. Restart the SSH service

$ sudo service ssh restart

  

Iv. running Google authenticator on your Android device

  1. Search and install Google authenticator in the Android app market.

 2. In the Configuration menu, enter the configuration information just

  3, add the completion of the 6-digit dynamic code will be

To this, the two-factor authentication configuration is complete!

Configuration Reference Link: https://linux.cn/article-3725-1.html

Configure SSH dual authentication for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.