How to reset a password on a VPS

This page will instruct you how to reset the ‘root’ or other user password on your VPS. This can be useful should you ever lose SSH access to the VPS, and are unable to login via the Emergency Console for troubleshooting.

Step-by-step instruction

  • The first step is to activate Rescue Mode for the VPS

  • Once rescue mode is activated, connect to the Emergency Console

  • While connected to the console, login to the Rescue Mode OS with the username ‘root’ and no password

  • Mount the system disk of your VPS, which under Rescue Mode, for a server with a single disk, will be /dev/xvdb1:

$ mkdir /mnt/d/
$ mount /dev/xvdb1 /mnt/d/


The system disk will always be the first partition of the last disk in /dev/, sorted alphabetically.

  • Next, prepare the chroot environment :

$ 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
  • And then chroot into the system :

$ chroot /mnt/d
  • Now you can change the root password using the passwd command, and then entering the new password when prompted :

$ passwd
  • Alternatively, you can change the password of your admin or other users by appending the username at the end of the passwd command :

$ passwd debian
  • After resetting the password, you can now quit chroot environment and unmount the folders from earlier :

$ 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/
  • Lastly, deactivate the rescue mode. From your Gandi dashboard, on your VPS configuration page, select ‘deactivate’. Your server will then restart automatically into normal mode.