Setting a complex password is the first step of securing any server.
But, what if you can’t remember the Vultr server root password few days after the setup ?
One of the solution is to reset the root password of your Vultr instance. And, this involves a series of steps depending on the server type.
At Bobcares, we often get requests from customers to recover root access to Vultr servers as part of our Technical Support Services for web hosts.
Today, we’ll see how our Cloud Engineers safely change the root password of Vultr server.
Need for root password reset in Vultr
Before proceeding further, let’s first see the scenarios where we generally need to change root password.
1. New servers
Usually, the initial root password details of a new Vultr server can be viewed from the Vultr Dashboard. To view the root password, we just need to clicking on the eye icon in the server page below.
But, when you change the root password via command line, it will not update in the Dashboard. And, if you forget it, all you can do is a root password reset.
2. Restore from another server snapshot
Vultr also allows to create new VPS based on the snapshot of existing server. Here, the root password will be the one that was set for the server at the time of snapshot.
From our experience in managing servers, we often see customers creating a VPS from old snapshot having problems with recovering root password. In all these situations, it becomes a necessity to change the root password.
How we change Vultr root password?
Managing a server requires root password. Let’s now see how our Dedicated Engineers reset the root password in Vultr server.
To change root password, we boot the server in a minimal working mode called “single user mode“. Let’s see the steps involved in this.
1. Restart the server
The first step is to restart the server.
For this, our Support Engineers access the console option and restart the server by clicking the “CTRL+ALT+DEL” button on the top right.
As the server starts, we press the ESC key to bring up the GRUB boot prompt.
2. Edit boot option
Here, at the boot prompt, we edit the boot option to change the working mode of the server. This step depends on the type of server.
For example, in a CentOS7 server, at the GRUB boot prompt, we press ‘E’ to edit the first boot option. Then edit the kernel line as
rw init=/sysroot/bin/sh
Similarly, in Debian or Ubuntu servers, we find the kernel line that starts with linux /boot/ and add init=/bin/bash at the end of the line.
After saving the file using F10 key, the system boots in single user mode.
Likewise, to boot CentOS6 server in single user mode, we type A to append to the boot command, add the text single and press ENTER.
3. Set new root password
Now that we are in single user mode, we need to set the new root password. This step also varies depending on the server type.
For this, in CentOS7 servers, our Support Engineers access the system with the command:
chroot /sysroot
passwd
The passwd command will prompt for the new password and we set a complex password for root.
4. Reboot the server
As the final step, we reboot the server once again. Now, we have reset the root password of the Vultr server.
Common errors with password reset
Just like any server, changing root password is not a one-click task. Therefore, we often see customers finding problems with Vultr root password change too. We’ll now see the top problems.
1. Commands for wrong server type
Often, customers attempt to use commands not suitable for their server type. For example, trying CentOS commands on an Ubuntu server will cause password reset to fail.
That’s why, our Support Engineers primarily check the server version and then proceed with the respective commands to reset password.
2. Copy/paste of commands
Similarly, copying and pasting of the commands will not work in Vultr console. And, we’ve seen customers making typo errors in the commands too.
To fix, we enter the command manually from the console and change the root password for the customer.
Proactive measure to avoid the need for password change
We just saw the series of steps to change the root password. Once we have accessed the server, our Dedicated Engineers go one step further and set up proper SSH keys on the Vultr server.
This method works with a private and public ssh key pair and do not need root password. Fortunately, even if you forget root password, ssh keys will grant you access to the server. Additionally, we set the VPS to only accept keys from trusted IP addresses.
Conclusion
Root password change in Vultr server involves a series of steps based on the type of servers. Today, we saw how our Cloud Engineers reset Vultr root password from console and fix common errors with it.
0 Comments