CN108984230B - Linux-based password resetting method and system - Google Patents

Linux-based password resetting method and system Download PDF

Info

Publication number
CN108984230B
CN108984230B CN201810822750.5A CN201810822750A CN108984230B CN 108984230 B CN108984230 B CN 108984230B CN 201810822750 A CN201810822750 A CN 201810822750A CN 108984230 B CN108984230 B CN 108984230B
Authority
CN
China
Prior art keywords
initramfs
password
script
file
linux
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810822750.5A
Other languages
Chinese (zh)
Other versions
CN108984230A (en
Inventor
刘骏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810822750.5A priority Critical patent/CN108984230B/en
Publication of CN108984230A publication Critical patent/CN108984230A/en
Application granted granted Critical
Publication of CN108984230B publication Critical patent/CN108984230B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/30Authentication, i.e. establishing the identity or authorisation of security principals
    • G06F21/31User authentication

Abstract

The invention provides a password resetting method and system based on Linux, comprising the following steps: s1, mounting the drive letter of the mobile device to/mnt; s2, writing grub into the mobile equipment; s3, writing the password reset script into the initramfs.img file to generate a new initramfs.img file; and S4, copying the initramfs. S5, modify the initramfs boot file of the grub. According to the invention, the password reset script is arranged in the mobile equipment such as the U disk, when the user forgets that the system password needs to be reset, the user selects to boot the mobile equipment from the U disk, and the built-in password reset script automatically runs, so that the password can be reset. The user does not need to remember to repeatedly try or enter the shell interface to reset the password by modifying the grub kernel starting parameter, and only needs to start the reset from the preset USB flash disk mobile device, so that the memory burden of the user is relieved, the password resetting process is simplified, and the password resetting of the user is facilitated.

Description

Linux-based password resetting method and system
Technical Field
The invention relates to the technical field of password resetting, in particular to a password resetting method and system based on Linux.
Background
In the Linux system, if a user forgets a password, the password is repeatedly tried by continuously recalling, or a complicated password resetting operation is performed by a disc rescue mode or by modifying grub kernel starting parameters to enter a shell interface, the grub kernel starting parameters are modified, and the password resetting operation can be completed through 9 steps.
The specific operation of modifying the grub kernel starting parameter is as follows:
in the starting grub menu, selecting an editing option to start; when the system is started to the grub interface, pressing an e key to enter an editing interface, inputting rd.break at the end of a line of Linux 16, and starting the system by pressing Ctrl + x; in the started shell interface, the file system is mounted again so as to be convenient for reading and writing; setting a root directory; modifying the root password; updating the SELinux strategy; exiting the chorot mode; restoring a system initialization interface; and restarting.
It can be seen from the above operation that the operation is too cumbersome and the practicality is poor for the password reset in the prior art, thereby greatly reducing the user experience.
Disclosure of Invention
The invention aims to provide a Linux-based password resetting method and a Linux-based password resetting system, which aim to solve the problems of complicated operation and poor practicability of password resetting in the prior art, realize simple operation, namely, the password resetting, simplify the operation and improve the user experience.
In order to achieve the technical purpose, the invention provides a password resetting method based on Linux, which comprises the following steps:
s1, mounting the drive letter of the mobile device to/mnt;
s2, writing grub into the mobile equipment;
s3, writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
and S4, copying the initramfs.
S5, modify the initramfs boot file of the grub.
Preferably, the operation of step S3 is specifically:
s301, decompressing an initramfs.img file;
s302, copying the password reset script to a list/lib/system directory;
s303, repacking the initramfs.img to generate a new initramfs.img file.
Preferably, the mobile device comprises a U disk and a mobile hard disk.
Preferably, the method further comprises:
judging the Linux version, and executing the corresponding password reset script.
Preferably, the Linux version comprises CentOS, RHEL, Ubuntu, Sles, Debian.
The invention also provides a password resetting system based on Linux, which comprises
The drive letter mounting module is used for mounting the drive letter of the mobile equipment to/mnt;
a grub writing module, configured to write grub into the mobile device;
the boot file regeneration module is used for writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
and the boot file copying module is used for copying the initramfs.
And the guide file redirection module is used for modifying the initramfs guide file of the grub.cfg file in the mobile equipment into a newly generated initramfs.img file.
Preferably, the boot file regeneration module includes:
the decompression unit is used for decompressing the initramfs.img file;
the script copying unit is used for copying the password resetting script to a list/system directory;
and the repacking unit is used for repacking the initramfs.img to generate a new initramfs.img file.
Preferably, the mobile device comprises a U disk and a mobile hard disk.
Preferably, the system further comprises:
and the version judging module is used for judging the Linux version and executing the corresponding password resetting script.
Preferably, the Linux version comprises CentOS, RHEL, Ubuntu, Sles, Debian.
The effect provided in the summary of the invention is only the effect of the embodiment, not all the effects of the invention, and one of the above technical solutions has the following advantages or beneficial effects:
compared with the prior art, the password resetting script is arranged in the mobile equipment such as the U disk, when a user forgets that the system password needs to be reset, the user presses the F11 key to select the starting equipment when the system is started, the starting equipment is guided by the U disk mobile equipment, and the built-in password resetting script automatically starts to run after the starting, so that the password resetting can be carried out. Through the method and the device, the user does not need to recall the complex operation of repeatedly trying or entering the shell interface to reset the password by modifying the grub kernel starting parameter, and only needs to start the reset from the preset USB flash disk mobile device, so that the memory burden of the user is reduced, the password resetting process is simplified, and the user can conveniently reset the password.
Drawings
Fig. 1 is a flowchart of a Linux-based password resetting method according to an embodiment of the present invention;
fig. 2 is a block diagram of a Linux-based password resetting system according to an embodiment of the present invention.
Detailed Description
In order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
The following describes a password resetting method and system based on Linux in detail with reference to the accompanying drawings.
As shown in fig. 1, the embodiment of the invention discloses a password resetting method based on Linux, which comprises the following steps:
s1, mounting the drive letter of the mobile device to/mnt;
s2, writing grub into the mobile equipment;
s3, writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
s4, copying the initramfs.img file containing the password reset script into the mobile equipment;
s5, modify the initramfs boot file of the grub.
And viewing the drive letter of the mobile device through the fdisk-1 under the system, wherein the drive letter is sdb4, and mounting the drive letter to/mnt:
#mount/dev/sdb4/mnt
writing grub into the mobile device:
#grub2-install--root-directory=/mnt--no-floppy/dev/sdb
#cp/boot/grub2/grub.cfg/mnt/boot/grub2/grub.cfg
writing a password reset script into an initramfs.
First decompress initramfs. img file:
#mkdir/tmp&cd/tmp
#/usr/lib/dracut/skipcpio/boot/initramfs-`uname-r`.img|gunzip-c|cpio-i–d
the reset script of password resetpwd.sh is then copied under the list/lib/system directory:
#cp ResetPwd.sh/lib/systemd/system
repacking initramfs.img:
#find.2>/dev/null|cpio--quiet-c-o|xz-9--format=lzma>"new_initramfs.img"
copying an initramfs.img file containing a password reset script into a mobile device:
#cp/tmp/new_initramfs.img/mnt/boot
modify initramfs boot file of grub.cfg file in mobile device to newly generated new _ initramfs.img:
#vim/mnt/boot/grub2/grub.cfg
the method comprises the steps of inserting a mobile device with a preset password resetting script into a server, selecting a starting item when starting, leading the server to be started from the mobile device, entering initramfs, executing the password resetting script ResetPwd.
The mobile device comprises a U disk, a mobile hard disk and the like.
When the password reset script runs, due to the fact that the Linux versions are many, such as CentOS, RHEL, Ubuntu, Sles, Debian and the like, password reset modes are different, and the script needs to judge the Linux version and execute the corresponding password reset script.
According to the embodiment of the invention, the password reset script is arranged in the mobile equipment such as the U disk, when a user forgets that the system password needs to be reset, the user presses the F11 key to select the starting equipment when the system is started, the starting equipment is guided by the U disk mobile equipment, and the built-in password reset script automatically starts to run after the starting, so that the password reset can be carried out. The user does not need to remember to repeatedly try or enter the shell interface to reset the password by modifying the grub kernel starting parameter, and only needs to start the reset from the preset USB flash disk mobile device, so that the memory burden of the user is relieved, the password resetting process is simplified, and the password resetting of the user is facilitated.
As shown in fig. 2, the embodiment of the present invention further discloses a password resetting system based on Linux, where the system includes:
the drive letter mounting module is used for mounting the drive letter of the mobile equipment to/mnt;
a grub writing module, configured to write grub into the mobile device;
the boot file regeneration module is used for writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
and the boot file copying module is used for copying the initramfs.
And the guide file redirection module is used for modifying the initramfs guide file of the grub.cfg file in the mobile equipment into a newly generated initramfs.img file.
The boot file regeneration module includes:
the decompression unit is used for decompressing the initramfs.img file;
the script copying unit is used for copying the password resetting script to a list/system directory;
and the repacking unit is used for repacking the initramfs.img to generate a new initramfs.img file.
The mobile equipment comprises a U disk and a mobile hard disk.
The system further comprises:
the version judging module is used for judging the Linux version and executing a corresponding password resetting script; the Linux version comprises CentOS, RHEL, Ubuntu, Sles and Debian.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.

Claims (8)

1. A password resetting method based on Linux is characterized by comprising the following steps:
s1, mounting the drive letter of the mobile device to/mnt;
s2, writing grub into the mobile equipment;
s3, writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
s4, copying the initramfs.img file containing the password reset script into the mobile equipment;
s5, modifying an initramfs boot file of a grub.cfg file in the mobile equipment into a newly generated initramfs.img file; the method comprises the steps of inserting a mobile device with a preset password resetting script into a server, selecting a starting item when starting, leading the server to be started from the mobile device, entering initramfs, executing the password resetting script, automatically judging a Linux version and executing a corresponding password resetting script after the password resetting script runs, and automatically restarting after the password resetting is finished.
2. The Linux-based password resetting method of claim 1, wherein the step S3 specifically operates as:
s301, decompressing an initramfs.img file;
s302, copying the password reset script to a list/lib/system directory;
s303, repacking the initramfs.img to generate a new initramfs.img file.
3. A Linux-based password resetting method as claimed in claim 1 or 2, wherein the mobile device comprises a usb disk and a mobile hard disk.
4. A Linux-based password resetting method as claimed in claim 1, wherein the Linux version includes CentOS, RHEL, Ubuntu, Sles, Debian.
5. A password resetting system based on Linux is characterized in that the system comprises
The drive letter mounting module is used for mounting the drive letter of the mobile equipment to/mnt;
a grub writing module, configured to write grub into the mobile device;
the boot file regeneration module is used for writing the password reset script into the initramfs.img file to generate a new initramfs.img file;
the boot file copying module is used for copying the initramfs.img file containing the password reset script into the mobile equipment;
the guide file redirection module is used for modifying an initramfs guide file of a grub.cfg file in the mobile equipment into a newly generated initramfs.img file; the method comprises the steps of inserting a mobile device with a preset password resetting script into a server, selecting a starting item when starting, leading the server to be started from the mobile device, entering initramfs, executing the password resetting script, automatically judging a Linux version and executing a corresponding password resetting script after the password resetting script runs, and automatically restarting after the password resetting is finished.
6. A Linux-based password reset system as recited in claim 5, wherein the boot file regeneration module comprises:
the decompression unit is used for decompressing the initramfs.img file;
the script copying unit is used for copying the password resetting script to a list/system directory;
and the repacking unit is used for repacking the initramfs.img to generate a new initramfs.img file.
7. A Linux-based password resetting system according to claim 5 or 6, wherein said mobile device comprises a USB flash drive or a mobile hard drive.
8. A Linux-based password reset system according to claim 5, wherein the Linux versions include CentOS, RHEL, Ubuntu, Sles, Debian.
CN201810822750.5A 2018-07-25 2018-07-25 Linux-based password resetting method and system Active CN108984230B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810822750.5A CN108984230B (en) 2018-07-25 2018-07-25 Linux-based password resetting method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810822750.5A CN108984230B (en) 2018-07-25 2018-07-25 Linux-based password resetting method and system

Publications (2)

Publication Number Publication Date
CN108984230A CN108984230A (en) 2018-12-11
CN108984230B true CN108984230B (en) 2021-04-09

Family

ID=64550272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810822750.5A Active CN108984230B (en) 2018-07-25 2018-07-25 Linux-based password resetting method and system

Country Status (1)

Country Link
CN (1) CN108984230B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110147311A (en) * 2019-04-03 2019-08-20 珠海全志科技股份有限公司 A kind of system upgrade method of calibration and device
CN109992947A (en) * 2019-04-11 2019-07-09 苏州浪潮智能科技有限公司 A kind of storage device password remapping method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662783A (en) * 2012-03-20 2012-09-12 浪潮电子信息产业股份有限公司 Method for repairing virtual machine under desktop cloud environment
CN102883229A (en) * 2012-09-10 2013-01-16 深圳创维数字技术股份有限公司 Running method and running device for control script of digital television
CN104007987A (en) * 2014-05-12 2014-08-27 浪潮电子信息产业股份有限公司 Script capable of carrying out automatic mounting under Linux
CN105260217A (en) * 2015-11-03 2016-01-20 国云科技股份有限公司 Method of password external reset of linux virtual machine
CN106407753A (en) * 2016-09-30 2017-02-15 郑州云海信息技术有限公司 Equipment safety protection method and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8429630B2 (en) * 2005-09-15 2013-04-23 Ca, Inc. Globally distributed utility computing cloud

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102662783A (en) * 2012-03-20 2012-09-12 浪潮电子信息产业股份有限公司 Method for repairing virtual machine under desktop cloud environment
CN102883229A (en) * 2012-09-10 2013-01-16 深圳创维数字技术股份有限公司 Running method and running device for control script of digital television
CN104007987A (en) * 2014-05-12 2014-08-27 浪潮电子信息产业股份有限公司 Script capable of carrying out automatic mounting under Linux
CN105260217A (en) * 2015-11-03 2016-01-20 国云科技股份有限公司 Method of password external reset of linux virtual machine
CN106407753A (en) * 2016-09-30 2017-02-15 郑州云海信息技术有限公司 Equipment safety protection method and system

Also Published As

Publication number Publication date
CN108984230A (en) 2018-12-11

Similar Documents

Publication Publication Date Title
US11508383B2 (en) Method for operating content and electronic device for implementing same
TWI576764B (en) A computer system
CN108984230B (en) Linux-based password resetting method and system
US20110154484A1 (en) Information processing apparatus, method of controlling authentication process, and recording medium
JP2006252547A (en) Application method of portable software
JP2012252701A (en) Data recovery and backup system and process
CN102135893A (en) Method for integrating operating system on BIOS (Basic Input Output System) chip and starting operating system on server
US9436828B2 (en) Systems and methods for command-based entry into basic input/output system setup from operating system
CN107239309B (en) Patch generation method and device, updating method, electronic device and storage medium
CN107391665A (en) The creation method and device of a kind of database instance
CN104866324A (en) Method for constructing portable operating system and portable memorizer
US9411602B2 (en) Techniques for booting an information processing system
CN109634659A (en) Method, apparatus, equipment and the storage medium that a kind of couple of BMC is controlled
CN109117153A (en) Processing method, device, terminal and the storage medium of application program
CN102135923A (en) Method for integrating operating system into BIOS (Basic Input/Output System) chip and method for starting operating system
US20140282836A1 (en) Enterprise device policy management
US8924306B2 (en) Remote computer rebooting tool
US20050289537A1 (en) System and method for installing software on a computing device
CN111399926A (en) Method and device for downloading starting program
CN113419814B (en) Virtual machine creating method, device, equipment and storage medium in cloud platform
US9032243B2 (en) Target operating system and file system agnostic bare-metal restore
WO2017096889A1 (en) Method and device for upgrading and downgrading system
CN112988207A (en) BIOS updating method, device, equipment and readable storage medium based on Setup interface
CN112463232A (en) Linux training machine
CN110716753A (en) Cloud host initialization method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant