Skip to content

Password change/reset on Linux servers

In this article

Note

The connection via IP KVM is used to recover a password on a dedicated server. On a virtual server - Virt-viewer. The password reset steps vary depending on the installed operating system.

Information

A detailed description of remote control methods is located here.

API Methods for Remote Access

CentOS

o reset or change the password on the server, perform the following steps. Points 1-5 apply only for virtual servers:

  1. Go to the Console tab of the service Invapi control panel;
  2. Press the Launch VNC console button:

  3. Enter the PIN code:

  4. Click on the downloaded file console.vv;

  5. In the opened console, click on the Keyboard icon in the upper left corner and select Ctrl+Alt+Delete from the list of options:

  6. The server will be rebooted. If this turns off the console, you need to re-open it through the Launch VNC console. button. As soon as booting from disk starts and a list of kernels available for booting appears for a few seconds, you should quickly press the E button on the keyboard, which will allow you to go to the configuration of kernel boot parameters:

  7. Scroll down to the line starting with the word Linux:

  8. Go to the end of this line (End key on the keyboard);

  9. Change the end of the line: quiet to init=\bin\bash and press the key combination Ctrl+X. This action will boot into bash;
  10. After loading bash, enter the command:

    mount -o remount,rw /
    

    which will put the file system in write mode.

    After entering the command, press Enter:

  11. Enter the passwd command and press Enter;

  12. Enter a new password and press Enter:

  13. Repeat entering the new password and press Enter;

  14. Enter the sync command and press Enter;
  15. Go to the Power tab of the control panel and reboot the server – Reboot button:

After rebooting the server, you can use the new password.

FreeBSD

After connecting KVM, you need to restart the server using the Ctrl+Alt+Del key combination. While the server is loading, the following window will be displayed:

You must select option numbered 4 – Boot FreeBSD in single user mode.

Next, the system will prompt you to specify shell. It is possible to choose two options – press the Enter or type /bin/csh:

If the server was restarted forcibly using the power button, then you should check the file system for errors:

/sbin/fsck -y

Then you should remount the file system in write mode:

/sbin/mount -o rw /

Next, you need to change the password (you must enter the new password twice):

/usr/bin/passwd root

At the end of the password change, you must restart the server:

/sbin/reboot

Debian

After connecting KVM, you need to press the Esc key at the moment the inscription Press ESC to going to menu is displayed on the screen and go to the GRUB menu:

hen you should switch to edit mode – press the E key and select the kernel line starting with the word kernel, and switch to edit mode again – E key.

At the end of the line, you need to add a parameter:

init=/bin/sh

Then press the Enter and B keys. After completing the above steps, the system will be booted into single-user mode.

Further, you need to remount the root file system in write mode:

mount -t proc none /proc
mount -t sysfs none /sys
/etc/init.d/udev start
mount -o remount,rw /

Next, you need to run passwd root and enter the new password twice. Then you should restart the server:

reboot

Ubuntu

To reset the password, you need to restart the server – press the key combination Ctrl+Alt+Del.

After loading the BIOS menu, but before the OS starts, you need to stop the boot timer and go to the GRUB menu – press any key except Enter.

You need to boot the OS in single-user mode and edit the bootstrap line. The arrows on the keyboard are used to move between the lines. You should highlight the line Ubuntu and go into edit mode – press the E key:

You should find the line that starts with linux /boot and replace the ro parameter with rw. You also need to add a new parameter init=/bin/bash.

Next, press the key combination Ctrl+X or F10. This action will boot the OS in single-user mode.

You need to enter the command in the console:

passwd root

And enter the new password twice:

Then you should save the changes:

sync

And reboot the system:

reboot –f