How to generate and use SSH keys in cPanel
This guide explains how to create and use SSH keys in cPanel so you can log in to your hosting account over SSH without typing a password. An SSH key pair has two parts: a private key that stays on your computer and a public key that you place on the server. It is much harder to guess than a password and protects you from brute-force attacks.
Method 1: Create the key on your computer (recommended)
Your private key never leaves your device with this method.
- Open PowerShell or Windows Terminal (Windows 10/11), or Terminal on macOS/Linux.
- Run the command below and press Enter to accept the default file location. Choose a passphrase to protect the key.
ssh-keygen -t ed25519 -C "you@example.com" - Show the public key and copy the whole line (it starts with
ssh-ed25519):
cat ~/.ssh/id_ed25519.pub - Log in to cPanel, open SSH Access in the Security section, then click Manage SSH Keys.
- Click Import Key, give the key a name, paste the public key in the public key box, leave the private key box empty, and click Import.
- Go back to the key list and click Manage next to the new public key, then Authorize. A key does not work until it is authorized.
ssh-keygen -t rsa -b 4096 and import id_rsa.pub.Method 2: Generate the key inside cPanel
- Open SSH Access > Manage SSH Keys > Generate a New Key.
- Enter a strong key password (passphrase), keep the key type and size defaults (RSA 4096 is a good choice), and click Generate Key.
- Back in the list, Authorize the new public key.
- Under Private Keys, click View/Download. Download the key, or use the Convert to PPK option if you use PuTTY.
- For security, delete the private key from the server after you download it.
Log in with your key
From PowerShell, macOS or Linux:
ssh -i ~/.ssh/id_ed25519 -p PORT cpanelusername@example.com Use the SSH port from your welcome email, or ask support if you are not sure. In PuTTY, go to Connection > SSH > Auth > Credentials and choose your .ppk file.
If you downloaded a key from cPanel on macOS or Linux, restrict its permissions first or SSH will refuse to use it:
chmod 600 ~/.ssh/mykey Tips
- Always use a passphrase. If your laptop is stolen, the key alone is not enough to log in.
- Use one key per device, so you can remove a single device later without affecting the others.
- Delete old keys from Manage SSH Keys when an employee or developer stops working with you.
- Never send your private key by email or chat. Only the public key (
.pub) is safe to share.
Common problems
- Still asks for a password: the key is not authorized, or SSH is using a different key. Authorize it in cPanel and pass the right file with
-i. - "UNPROTECTED PRIVATE KEY FILE": run
chmod 600on the key file as shown above. - PuTTY says "unable to use key file": PuTTY needs the
.ppkformat. Convert the key in cPanel or with PuTTYgen.
Frequently asked questions
Do I need shell access enabled to use keys?
Yes. Keys are only a login method. See how to use Terminal and SSH access on shared hosting first.
Can I use the same key for Git deployment?
Yes, cPanel Git Version Control and services like GitHub use the same SSH key format.
What if I lose my private key?
Delete the old public key from cPanel and create a new pair. You can still log in with your password or the cPanel Terminal meanwhile.