Why You Might Need to Change the Root Password

Changing the root password is a basic yet essential security measure for anyone managing a Linux server. Whether you suspect a breach, want to improve security, or simply forgot the original root password, this guide will walk you through it safely.

Pro Tip: Always use a strong password with a mix of letters, numbers, and symbols.


Prerequisites

Before you begin, make sure you have:

  • Root or sudo privileges

  • SSH access to your server

  • A terminal (like PuTTY or your local shell)


✅ Method 1: If You’re Already Logged In as Root

  1. Open the terminal or SSH into your server.

  2. Type the following command:

     
    passwd
  3. Enter your new root password when prompted.

  4. Confirm it again.

  5. You’ll see a message like:
    password updated successfully


Method 2: If You’re Using a Sudo User

  1. SSH into the server using your sudo user.

  2. Type:

     
    sudo passwd root
  3. Enter your own sudo password if prompted.

  4. Enter and confirm the new root password.


Forgot Root Password? (Recovery Mode)

If you're locked out and can access the server through a console or GRUB boot:

  1. Reboot the server and enter GRUB menu.

  2. Choose the default kernel and press e to edit.

  3. Find the line starting with linux, go to the end, and add:

     
    init=/bin/bash
  4. Press Ctrl + X or F10 to boot.

  5. Once in bash, remount the system:

     
    mount -o remount,rw /
  6. Now reset the password:

     
    passwd
  7. Enter your new password.

  8. Type:

     
    exec /sbin/init
  9. Reboot and log in with the new root password.


Final Tips for Root Password Security

  • Use long, complex passwords.

  • Disable direct root login and use a sudo user for routine tasks.

  • Consider using SSH keys instead of passwords.


Need Help?

If you're hosting with Vastrox and run into trouble, our support team is available 24/7 to assist with server access and security. Contact Support

Răspunsul a fost util? 0 utilizatori au considerat informația utilă (0 Voturi)

Powered by WHMCompleteSolution