How to Reset the Root Password on a Cloud Server

This page describes how to reset the root password of your server in the case that you forget it.

Gandi provides a ramdisk-rescue kernel to simplify the process of resetting your root password. You will need to complete these steps:

  1. Change the kernel used by the server to ramdisk-rescue.

  2. Restart the server.

  3. Connect to the emergency console.

  4. Chroot the environment.

  5. Reset the kernel and restart your server.

These steps are explained in more detail below.

Step 1: Change the Kernel

Follow our directions for changing the boot system on a volume and choose ramdisk-rescue as your boot system.

Important

Make sure you note the original kernel used, since you will need to switch back after resetting your password.

Step 2: Restart the Server

Follow our directions for restarting your server.

Step 3: Connect to Emergency Console

Follow our directions for connecting to your emergency console.

Step 4: Chroot the Environment

When connected , create a /mnt/d folder in order to mount your disk:

# mkdir /mnt/d
# mount /dev/xvda1 /mnt/d

Now, prepare chroot:

# mount --bind /dev/ /mnt/d/dev
# mount --bind /dev/pts /mnt/d/dev/pts
# mount --bind /proc/ /mnt/d/proc
# mount --bind /sys/ /mnt/d/sys

Then, make chroot:

# chroot /mnt/d

Now, change the root password with the passwd command:

# passwd

Quit chroot environment and unmount these folders:

# exit
# umount -v /mnt/d/dev/pts
# umount -v /mnt/d/dev/
# umount -v /mnt/d/sys
# umount -v /mnt/d/proc
# umount -v /mnt/d/

Step 5: Switch Back Kernel and Restart the Server

You can now switch back to the original server kernel. Be sure to also do a stop and start of the server to be sure your changes take effect.