Daren Hall: teach you to easily restore Linux password

  

When we use Linux system, if you have not logged in for a while, you lost the Root password, what should I do? Is it helpless and reinstalling the system? How can I recover my Linux password? This article explains the knowledge of restoring Linux passwords.

In fact, restoring Linux passwords is not a very difficult thing. There are two aspects to recovering Linux passwords: one is to create a new password for the user, so that the user can log in to the system again; the second is to find the user's original password instead of replacing the old password with a new one. Under normal circumstances, users only want to be able to log in to the system again, instead of obtaining the original password, which is the first aspect mentioned here, relatively speaking, this aspect is much easier to implement.

Linux password recovery is a typical case of system maintenance. Some methods mentioned in this article are not only applicable to Linux password recovery, but also for some reasons. The maintenance work when logging in to the system has a reference function for the management and maintenance of the Linux system.

All the methods mentioned in this article to recover Linux passwords are tested in practice. The Linux system used is mainly RedHat Linux For x86. In actual password recovery, it may be due to Linux publishers, distributions, The processor and the hard disk are slightly different, but the difference is not large. Some of these methods are also applicable to the recovery of passwords on other Unix systems, and even the recovery of operating system passwords such as Windows.

1. Emergency Repair Mode

When Linux cannot be started, it is often necessary to boot the Linux basic environment by disk, CD or other methods to enter the Linux emergency repair mode. In the emergency repair mode, you can access the Linux system files on the hard disk and restore the system to normal, including restoring passwords.

2. Single-user mode Linux has multiple run levels, such as single-user mode, no network service multi-user mode, full multi-user mode, and X11 graphical multi-user mode.

Single-user mode means that the system runs in the unique user-Root user mode. When entering this mode, the system only loads the minimum software and hardware configuration that can be run, and the root directly enters without password verification.

In single-user mode, you can use the passwd command to change the user password, or you can directly read and write the account password file such as /etc/passwd to achieve password recovery.

3. Modify password file

There are two ways to save the Linux password file: One is to save the account information and the encrypted password ciphertext in the /etc/passwd file. This form is not secure enough. The other is to store the account information and password ciphertext separately, the /etc/passwd file is used to save the account information, and the /etc/shadow file is used to save the password ciphertext. As for the storage format and encryption algorithm, you can use the /usr/sbin/authconfig program to set it.

For a passwd file without a shadow, simply delete the password field of the corresponding account and log in directly to the system without password verification. For example, the root account of a passwd file is as follows:

root:$1$ dPTzzYkE$Zd3Vs6yCu

VH8RC1gwKXX01:0:0:root:/root:/bin/bash

Modify it to:

root::0:0:root: /root:/bin/bash

If there is a shadow passwd file, the password field is replaced by the "x" letter, and the password ciphertext is stored in the shadow file. You can delete the "x" letter in the passwd file, or delete the password ciphertext in the shadow file, so that the corresponding user can log in directly to the system without password verification, achieving the purpose of password recovery.

4. Password Restore

In some cases, you want to find out the original password that was lost, instead of logging into the system to generate a new password. However, Linux uses DES (Crypt for encryption function) or MD5 (for Md) encryption algorithms. Due to the large amount of computation, they are almost impossible to be reverse-hacked. The DES password ciphertext is a string of 13 ASCII characters, and the start character of the MD5 password ciphertext is always "$1$".

Although it is difficult to reverse the crack, it is not impossible to find the original password through the password ciphertext. The string is extracted from a dictionary or a combination of characters. The extracted string uses the same The encryption algorithm encrypts and compares the generated ciphertext with the password ciphertext. If it is consistent, it indicates that the string is the original password, thereby achieving the purpose of password restoration. If the password is complex, it is difficult to find the original password using this method, but the user will have a rough impression of the length of the password, the characters used, etc., which makes the possibility of success even greater.

There are many tools for cracking Linux passwords, such as John the Ripper, Crack by Alex Muffett, and Cracker Jack. Among them, John the Ripper is the most powerful and fastest.

5. System Attack Cracking

If you can turn off the power and restart the system, it is easy to recover the password, but sometimes the Linux system runs a very important service, you can not directly turn off the power, otherwise it will damage the system and data.

It is often difficult to obtain a system password like this in the case of system operation, but because the system administrator has a comprehensive understanding of the operating system and application version, configuration, etc., plus no Protection against firewalls and intrusion detection systems, etc., there are still many opportunities to discover and exploit system vulnerabilities, and the chances of successful password recovery are still there.

The content involved in this aspect is too complicated, so I will not introduce it here. If there is a need in this area, it is best to have a professional to help, so as not to damage the system and data.

Easily recover your Linux password so you don't have to worry about it.

Copyright © Windows knowledge All Rights Reserved