How to Enable Root Login on Your Dedicated Server (and When Not To)

Enabling root login on your dedicated server allows direct access to the server with full administrative privileges. While this can be useful in some scenarios, it’s also risky if not handled carefully. In this guide, you’ll learn how to enable root login, secure it, and understand situations where enabling root login might not be advisable.

Step 1: Connect to Your Server via SSH
Before you begin, connect to your server using SSH with an existing non-root administrative user.

  • Use an SSH client like PuTTY for Windows or the terminal for macOS/Linux.
  • Run the following command to log in as an administrator:
    ssh user@your-server-ip
    
    Replace user with your username and your-server-ip with your server's IP address.

Step 2: Open the SSH Configuration File
The SSH configuration file controls login behavior for your server.

  • Once logged in, open the file using a text editor:
    sudo nano /etc/ssh/sshd_config
    
    Replace nano with your preferred text editor if necessary.

Step 3: Locate the Root Login Directive
Search for the following line in the configuration file:

  • Look for:
    PermitRootLogin
    
  • If the line is commented out (prefixed with a #), remove the # to uncomment it.

Step 4: Enable Root Login
Modify the PermitRootLogin directive to allow root login:

  • Change the value to:
    PermitRootLogin yes
    
  • This explicitly allows root login.

Step 5: Save and Exit the Configuration File
After making the changes:

  • Press CTRL + O to save the file in nano.
  • Press CTRL + X to exit the editor.

Step 6: Restart the SSH Service
For the changes to take effect, restart the SSH service:

  • Run the following command:
    sudo systemctl restart sshd
    

Step 7: Test Root Login
Open a new SSH session and attempt to log in as root:

  • Run the command:
    ssh root@your-server-ip
    
  • Enter the root password when prompted.

When Not to Enable Root Login

Enabling root login can expose your server to security risks, especially brute force attacks. Consider these alternatives:

  • Use Non-Root Accounts: Create a non-root user with sudo privileges for day-to-day operations.
  • Enable Key-Based Authentication: Use SSH keys to authenticate instead of passwords for better security.
  • Disable Root Login After Use: If root login is only required temporarily, disable it afterward by setting PermitRootLogin no in the configuration file.

Best Practices for Securing Root Access

  • Strong Passwords: Ensure the root password is complex and unique.
  • Restrict IPs: Limit root access to trusted IPs using firewall rules.
  • Monitor Logins: Regularly review server access logs for suspicious activity.

By following this guide, you can enable root login when necessary and understand the precautions to ensure your dedicated server remains secure. For further assistance, feel free to reach out to our support team.

Was this answer helpful? 0 Users Found This Useful (0 Votes)