How to Set Up SSH Key Authentication for WHM Root Login

How to Set Up SSH Key Authentication for WHM Root Login

Securely accessing your WHM server using an SSH key eliminates the need to enter a password each time while improving security. Follow this step-by-step guide to configure SSH key authentication for WHM.


Step 1: Generate an SSH Key (If You Don’t Have One)

If you already have an SSH key (id_rsa.pub), skip this step.

On your local computer, generate an SSH key using:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Press Enter for all prompts to use the default path (~/.ssh/id_rsa).


Step 2: Log in to WHM

  1. Open your WHM control panel in a browser: https://your-server-ip:2087
  2. Log in as root.

Step 3: Navigate to SSH Key Management

  1. In WHM, search for “Manage root’s SSH Keys” or go to: WHM » Security Center » Manage root’s SSH Keys
  2. Click “Import Key”.

Step 4: Add Your SSH Public Key

  1. Leave “Private Key” empty (you only need the public key).
  2. Paste your SSH public key into the “Public Key” field:
    • On your local machine, run: cat ~/.ssh/id_rsa.pub
    • Copy the full output and paste it into WHM.
  3. Give it a name (e.g., my-laptop-key).
  4. Click “Import”.

Step 5: Authorize the SSH Key

  1. Return to Manage root’s SSH Keys.
  2. Find your key in the list and click “Authorize”.

Step 6: Test SSH Login

Now, try logging in from your local machine without a password:

ssh root@your-server-ip

If successful, your SSH key authentication is set up correctly!


(Optional) Step 7: Disable Password Login for Security

For better security, disable password authentication:

  1. Go to WHM » Security Center » SSH Password Authorization Tweak.
  2. Set “Disable Password Authentication for SSH” to ON.

Now, only SSH keys will be accepted for root logins.


Conclusion

You have successfully configured SSH key authentication for WHM root login. This method enhances security and convenience, ensuring only authorized devices can access your server. 🚀

Leave a Comment