Восстановить пароль ROOT на ClearOS можно 2-мя способами, но только если вы имеете к нему физический доступ с подключенной клавиатурой и монитором.
- метод восстановления системы
- загрузка с флешки или диска и снова переход в режим восстановления
Эта процедура описывает метод восстановления для ClearOS 7. Для ClearOS 6, смотрите здесь. Для ClearOS 5, перейдите сюда.
Методы восстановления
Существует 3 метода восстановления ‘root’ пароля:
-
– Изменить пароль под другим административным аккаунтом (самый легкий вариант, но при наличии другого административного аккаунта)
-
– Сброс через ‘rd.break’ (легко, требуется прямой доступ к компьютеру и выполнение нескольких команд при начальной загрузке)
-
– Установочный носитель для установки системы в режиме восстановления (легко, требует точных команд и установочного носителя для ClearOS 7)
Сброс с помощью другого системного аккаунта
Если вы включили пользователя в группу ‘wheel’ , вы можете легко поменять пароль из командной строки (ctrl-alt-f1 например – зайти под своим пользователем и паролем) на консоли или через ssh-логин. Затем выполните команду ниже и поменяйте пароль:
sudo passwd root
Если такой пользователь у вас не настроен, то можно использовать метод сброс рут пароля методом rd.break.
Changing the Root Password Using rd.break
To change the root password using the rd.break method, you will need to be physically in front of the server with a monitor and a keyboard. You will also need to be able to take the server down with a couple of reboots.
With a monitor and keyboard attached, reboot the server. At the GRUB screen, interrupt the count down by pressing any key on the keyboard such as the spacebar.
With the countdown interrupted, select the kernel line corresponding to the environment you are running. Typically this is the default line. If it is not, use the arrow keys to navigate and press Enter.
Next, press the e key to edit the selected item.
The boot parameters for your server will appear. You can use the arrow keys to navigate down in this file. Locate the line that starts with ‘linux16’ (for most x86_64 system), ‘linux’ (for IBM Power Series), or ‘linuxefi’ (for systems which utilize UEFI.)
In this file, you need to remove some parameters and add some others (you can hop to the start of the line with Ctrl+a and the end of the line with Ctrl+e). Remove the parameters name ‘rhgb‘ and ‘quiet‘ by navigating to the end of the word and hitting backspace on your keyboard.
Next, add the following to the very end of the line by navigating to the end and adding a space. Add the parameters ‘rd.break enforcing=0‘
When the changes are made, you will need hold the control key and press x, then release (‘Ctrl+x‘. As indicated in the text at the bottom of your screen.)
The system will boot to a command prompt. If you have encrypted partitions, the system will need the password key to decrypt the file-system. You may not see the prompt for this unless you hit the backspace key to get back to the prompt.
switch-root:/#
At this prompt, you will need to enter several commands. The first changes your file system from the default read-only mode to read/write mode.
mount -o remount,rw /sysroot
Next, you will need to set this root as your running root partition:
chroot /sysroot
Your prompt will change to:
sh-4.2#
Change the root password by issuing the following command:
passwd
Changing password for user root New password:
If you have used a weak password (one based on a dictionary word) it may state:
BAD PASSWORD: it is based on a dictionary word
In this mode, it will take weak passwords in spite of the fact that they are weak.
-
You will then be asked to re-enter the password to confirm it and will subsequently receive a confirmation that the root password has been reset.
Retype new password: passwd: all authentication tokens updated successfully.
Next, we need to touch a file to indicate to a potentially enable SELinux that our changes are valid. Skipping this step is not advised.
touch /.autorelabel
Next, remount the existing filesystem back to the default rd.break mode of read-only:
mount -o remount,ro /
Next, type ‘exit‘ and ‘Enter‘ the change root environment:
exit
This will change your prompt back to:
switch-root:/#
Type ‘exit‘ and ‘Enter‘ again to reboot.
exit
Changing the Root Password from Install Media
Boot the server from the installation media. You will need to use the same mechanisms that you used to install the system. In most cases this is straight forward. With systems that required disk drivers in order to see partitions, you will need to use those same methods to mount the disks to modify the ‘root’ password.
At the start screen, navigate with the arrows to select ‘Troubleshooting’
Press <ENTER>.
At the troubleshooting screen, select ‘Rescue a ClearOS System’ and press <ENTER>.
After a while a blue screen will come up.
Use the arrow or tab keys to select ‘Continue‘. Press <ENTER>.
The system will attempt to find your ClearOS partition. If this step was not successful, you may need to load special drivers or contact support for assistance. If it finds your partition, it will notify you that the partition was found and mounted under ‘/mnt/sysimage’. Press <ENTER>.
For extra measure, we will notify you that your partition is mounted under ‘/mnt/sysimage’. Press <ENTER>.
You will be dropped to a command prompt. Your prompt will look similar to the following:
sh-4.2#
-
Type the command
chroot /mnt/sysimage
and press Enter. You will see the following:
bash-4.2#
-
Type the command
passwd
and press Enter. You will see the following:
bash-4.2# passwd Changing password for user root New UNIX password:
If you have used a weak password (one based on a dictionary word) it may state:
BAD PASSWORD: it is based on a dictionary word
In this mode, it will take weak passwords in spite of the fact that they are weak.
-
You will then be asked to re-enter the password to confirm it and will subsequently receive a confirmation that the root password has been reset.
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
-
Type the command
exit
and press Enter. You will see the following:
sh-4.2#
-
Type the command
exit
and press Enter. The system will be rebooted.