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
- Open your WHM control panel in a browser:
https://your-server-ip:2087
- Log in as root.
- In WHM, search for “Manage root’s SSH Keys” or go to:
WHM » Security Center » Manage root’s SSH Keys
- Click “Import Key”.
Step 4: Add Your SSH Public Key
- Leave “Private Key” empty (you only need the public key).
- 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.
- On your local machine, run:
- Give it a name (e.g.,
my-laptop-key
). - Click “Import”.
Step 5: Authorize the SSH Key
- Return to Manage root’s SSH Keys.
- 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:
- Go to WHM » Security Center » SSH Password Authorization Tweak.
- 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. 🚀