一、centos主机密码重置
-
进入引导界面,默认选择第一行,按“e”进行编辑
-
选择linux16开头的行,行尾输入 rw init=/sysroot/bin/sh,输入完成按 Ctrl+x启动
-
进入系统
-
顺序执行图中命令进行重置密码
-
重启完就可以使用新密码进去系统
二、Euler主机重置密码
-
进入引导界面,默认选择第一个,按“e”后需要输入grub的账号密码:root/openEuler#12
-
进入编辑界面
-
在linux开头的行尾添加 rw init=/bin/sh,按ctrl+x 启动主机
-
进入系统
-
使用passwd重置密码,出现updated successfully表示重置密码成功。
-
需要强制重启主机,重启完成后就可以使用新密码登陆主机了
三、Ubuntu重置密码
- 进入引导界面,选择Advanced options for Ubuntu,按回车进入
- 如下界面
- 选择带有 recouvery mode 最新版本的那一行,按“e”进入编辑界面
- 在linux开头的行,把ro recovery nomodeset 换成 rw single init=/bin/bash,假如原来还有dis_ucode_ldr就把他删除,修改完成按 ctrl+x启动系统
- 进入系统重置密码,重置成功后,强制重启系统,使用新密码登陆系统
Windows主机密码重置
Windows密码重置需要借助linux系统,在linux系统上安装ntfs-3g和chntpw,ntfs-3g用于把Windows NTFS系统挂载到linux,chntpw用于修改windows密码文件。linux操作系统使用centos7.6,非最小化安装。
- 安装ntfs-3g
下载地址:https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz
[root@resetpassword ~]#
[root@resetpassword ~]# tar -xf ntfs-3g_ntfsprogs-2017.3.23.tgz
[root@resetpassword ~]# cd ntfs-3g_ntfsprogs-2017.3.23/
[root@resetpassword ntfs-3g_ntfsprogs-2017.3.23]# ./configure && make && make install
- 安装chntpw
下载chntpw安装包:
wget http://li.nux.ro/download/nux/dextop/el7/x86_64//chntpw-0.99.6-22.110511.el7.nux.x86_64.rpm
当前使用的chntpw安装包和centos7.6系统可以直接安装,没有依赖关系。 - 把windows系统盘挂载到此linux主机
- 使用chntpw重置主机密码
[root@resetpassword config]# cd /mnt/Windows/System32/config/
[root@resetpassword config]# cp -a SAM SAM.bak #备份密码文件,密码文件损坏会导致进不去windows系统
[root@resetpassword config]#
[root@resetpassword config]# chntpw -u Administrator SAM #修改SAM文件中的Administrator用户信息,如果对用户名进行过修改,请使用修改后的用户名。
chntpw version 0.99.6 110511 , (c) Petter N Hagen
Hive <SAM> name (from header): <\SystemRoot\System32\Config\SAM>
ROOT KEY at offset: 0x001020 * Subkey indexing type is: 666c <lf>
File size 262144 [40000] bytes, containing 7 pages (+ 1 headerpage)
Used for data: 301/27056 blocks/bytes, unused: 16/1392 blocks/bytes.
………… #中间部分省略
Failed login count: 0, while max tries is: 0
Total login count: 25
- - - - User Edit Menu:
1 - Clear (blank) user password
2 - Edit (set new) user password (careful with this on XP or Vista)
3 - Promote user (make user an administrator)
(4 - Unlock and enable user account) [seems unlocked already]
q - Quit editing user, back to user select
Select: [q] > 1 #1为清除密码,当把windows系统盘盘重新挂载到源主机,不需要使用密码就可以登陆系统
Password cleared!
Hives that have changed:
# Name
0 <SAM>
Write hive files? (y/n) [n] : y #保存修改信息
0 <SAM> - OK
[root@resetpassword config]#
- 卸载windows系统盘挂载到原来主机就可以使用空密码进行登陆了。