Change the root password of your Linux VPS
Connect with SSH, type passwd, then enter the new password twice.
Change the password
- 1.From your very first login, connect to your VPS with SSH. The starting password should not stay in place.
- 2.Type
passwd, then Enter. - 3.Enter the new password, then Enter. Nothing appears while you type, that is normal.
- 4.Enter it a second time to confirm.
- 5.The message
password updated successfullyconfirms the change. On Rocky Linux and AlmaLinux, it readsall authentication tokens updated successfully.
Logged in as another user? Type sudo passwd root to change the root password, or sudo passwd alice for another user.
Keep your session open and test the new password from a second terminal before closing it.
Choose a good password
Use a long password, at least 16 characters, that you use nowhere else. A password manager remembers it for you.
To generate a random one, type openssl rand -base64 18 in the terminal.
If you lost the password
passwd needs you to be logged in already. If you have an SSH key installed on the VPS, log in with it, then type sudo passwd root.
Without a key, open a ticket from your client area. As a last resort, reinstalling the VPS from the client area starts from scratch: it erases your data.
To go further, switch to an SSH key and secure your VPS.