Comprehensive Guide to Linux Two-factor Identity Authentication: ssh + console + graphical interface

0 25
For our daily operation and maintenance personnel, Linux should be something we...

For our daily operation and maintenance personnel, Linux should be something we often deal with (if not, maybe it's not operation and maintenance, but maintenance...just kidding), the status of Linux in the data center is as unbreakable as that of Windows in the office space. The deployment of various software is首选 Linux! The three most commonly used login entries for Linux operation and maintenance are:

Ssh, console, and graphical interface (if any).

Comprehensive Guide to Linux Two-factor Identity Authentication: ssh + console + graphical interface

To ensure more secure operation and maintenance, two-factor identity authentication system dynamic passwords are usually used to strengthen login security. Let's briefly discuss how to strengthen two-factor authentication for these three entry points?

Firstly, a two-factor identity authentication system will be deployed to bind accounts and tokens one by one, activate tokens, and manage tokens;

Then deploy the pam_radius plugin on the Linux host to create a dynamic password input box;

Finally, modify the Linux file to enable the two-factor authentication module for ssh, console, and graphical interface;

Isn't it simple? Alright, let me take centos7.8 (installed with gnome) as an example:

1654828671_62a2ae7f43a8a361cf4b2.png!small?1654828671375

1、Two-factor authentication server

On this side, I use the Zhongke Helun two-factor identity authentication service, and the specific configuration method is not publicly available. You can enter the Zhongke Helun official website and contact us to obtain the installation package and configuration method

2、Deploy pam_radius plugin on Linux host

There are two packages in the plugin: libCkey.so and pam_radius_auth.so

1654828680_62a2ae884a9c5431518fd.png!small

Place the so in /usr/lib64

Place the so in /usr/lib64/security

Up to this point, the plugin is done, isn't it very simple?

3、Modify the corresponding file

Here, although there are 3 entries, actually two files are loaded, among which the file loaded by console is " /etc/pam.d/system-auth ", and the files loaded by ssh and the graphical interface are the same, " /etc/pam.d/password-auth ". Therefore, the focus needs to be paid to these two files, as follows:

Configure authentication server (this step is common!)

# mkdir /etc/raddb //Create the raddb folder (name fixed)
# vim /etc/raddb/server  //Configure authentication server information, the name of 'server' cannot be changed
  172.16.146.132   12345678   10
  Authentication server address     Shared secret     Timeout time

Configureconsole two-factor authentication

# vim /etc/pam.d/system-auth

Let's put the comparison diagram of modification before and after directly, as the text description is a bit tedious

1654828789_62a2aef512cfee8180410.png!small?1654828789447

△ Before modification

1654828794_62a2aefa27f0222f0c0a3.png!small?1654828794468

△ After modification

Login effect (console)

Login //Username

Password //Local static password

CkeyPassword //Dynamic password

1654828879_62a2af4f9111c5e174516.png!small?1654828880250

Up to this point, dynamic password login to console is implemented to achieve two-factor authentication.

Configure ssh and graphical interface two-factor authentication

Firstly, you need to modify"/etc/ssh/sshd_config "

# vim /etc/ssh/sshd_config
    PasswordAuthentication no
    ChallengeResponseAuthentication yes
    UsePAM yes

1654828890_62a2af5a1226c825a1ebd.png!small

Then modify "/etc/pam.d/password-auth"

# vim /etc/pam.d/password-auth

The modification method here is consistent with system-auth

1654828901_62a2af65aadf0983bd174.png!small

△ Before modification

1654828993_62a2afc1cd9700a66d56c.png!small?1654828994147

△ After modification

Login effect (ssh)

If it is a graphic tool, select the authentication method: Keyboard Interactive, and use ssh directly in the command line

1654829001_62a2afc912a9d203b8eb6.png!small?1654829001221

1. Enter the username

1654829005_62a2afcdeba30f9fca164.png!small?1654829006127

2. Enter the local static password

1654829010_62a2afd26039a5380f6fb.png!small?1654829010939

3. Enter the dynamic password

1654829015_62a2afd7188e45e0e6af0.png!small?1654829015965

Login effect (graphical interface)

1. Enter the username

1654829020_62a2afdc2139361272431.png!small?1654829020767

2. Enter the local static password

1654829025_62a2afe12b138e7198e89.png!small?1654829025589

3. Enter the dynamic password

1654829032_62a2afe8b6d98761b5240.png!small?1654829039816

Up to this point, double-factor authentication has been implemented on all 3 login entries, achieving secure access to Linux hosts.

There are many resources online about the benefits of using dynamic passwords, and I will not elaborate on this here. I will also write a dedicated article later, tentatively titled "The Principle and Advantages of Two-Factor Authentication Dynamic Password Technology" for your reference!

你可能想看:

It is possible to perform credible verification on the system boot program, system program, important configuration parameters, and application programs of computing devices based on a credible root,

d) Adopt identification technologies such as passwords, password technologies, biometric technologies, and combinations of two or more to identify users, and at least one identification technology sho

b) It should have a login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal login attempts, and automatically logging out w

b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo

Ensure that the ID can be accessed even if it is guessed or cannot be tampered with; the scenario is common in resource convenience and unauthorized vulnerability scenarios. I have found many vulnerab

Article 2 of the Cryptography Law clearly defines the term 'cryptography', which does not include commonly known terms such as 'bank card password', 'login password', as well as facial recognition, fi

Analysis of SSRF Vulnerability in Next.js: A deep exploration of blind SSRF attacks and their preventive strategies

Grade Protection Evaluation: Detailed Explanation of CentOS Login Failure Parameters and Two-Factor Authentication

Completely separable two-dimensional vector graph encryption domain robust reversible watermark algorithm (Part 1)

In today's rapidly developing digital economy, data has become an important engine driving social progress and enterprise development. From being initially regarded as part of intangible assets to now

最后修改时间:
admin
上一篇 2025年03月28日 02:06
下一篇 2025年03月28日 02:29

评论已关闭