Private GitHub repository on cPanel hosting: setting up a read-only deploy key (ed25519)
PrintIn short: cPanel can only clone a private GitHub project if it holds a key that GitHub trusts. Generate an ed25519 key pair on your own computer with no passphrase, register the public half on GitHub as a read-only deploy key, import the private half into cPanel under the name id_ed25519, and clone with the git@github.com:... address. Shell access to the hosting is not needed for any of this.
When your code is public, cPanel simply downloads it over HTTPS. A private repository is closed to everyone who cannot prove who they are, and that includes your hosting account. A deploy key is the proof: a key tied to one repository that lets cPanel read the code and nothing more.
The pieces involved
| Piece | File name in this guide | Where it ends up |
|---|---|---|
| Public key | site-key.pub | GitHub, in the repository settings |
| Private key | site-key | cPanel only, imported as id_ed25519 |
| SSH clone address | git@github.com:username/site.git | The Clone URL field in cPanel |
Part 1. Generate the key pair
Use PowerShell on Windows 10 or 11, or Terminal on macOS and Linux:
ssh-keygen -t ed25519 -C "cpanel-site" -f site-key
The tool asks for a passphrase twice. Leave it blank both times by pressing Enter. Two files appear in the current folder: site-key.pub and site-key.
Part 2. Register the public key on GitHub
- In the repository on GitHub, go to Settings and choose Deploy keys, then Add deploy key.
- Give it a Title you will recognise later, such as "cPanel TopHost".
- Open
site-key.pubin Notepad or another plain text editor, copy everything and paste it into Key. - Make sure Allow write access stays empty, then confirm with Add key.
Part 3. Hand the private key to cPanel
- In cPanel, open SSH Access from the Security group and go to Manage SSH Keys.
- Choose Import Key. As the name, type
id_ed25519and nothing else: Git looks for that exact file name and ignores keys called differently. - Paste the whole content of
site-keyinto the private key box. The lines that begin and end the key must be included. - Keep the passphrase box blank and press Import.
The Authorize button can be skipped. It controls logins to the server over SSH and has no role in talking to GitHub.
Part 4. Clone over SSH
On GitHub, press the Code button and copy the address from the SSH tab. Then in cPanel go to Git Version Control under Files, press Create, paste that address into Clone URL, pick a folder like repositories/site and press Create again. From here on, updating and publishing the site work exactly as with a public project, see Git deployment on cPanel hosting: clone a GitHub repository and publish it with .cpanel.yml.
Is a key without a passphrase a risk?
A passphrase would have to be typed every time cPanel contacts GitHub, and cPanel runs these fetches without a person present, so a protected key would simply not work. The exposure is small: the key opens a single repository, and as long as write access was left off, it can read but never change anything.
Error messages and fixes
| You see | Likely reason and what to do |
|---|---|
Permission denied (publickey) | Check three things: the key in cPanel is named id_ed25519, you pasted the private file and not the .pub one, and the deploy key was added to this very repository. |
Repository not found | There is a typo in the address, or the key was registered on a different repository. |
Key is already in use on GitHub | GitHub accepts a deploy key on one repository only. Generate a fresh pair for each repository. |
| Everything looks right, cloning still fails | Contact us by ticket and we will look at the setup in your account. |
Questions we often get
Can one key serve two or more private repositories?
No, an id_ed25519 key covers one repository. If you need several, write to us in a ticket and we will help you set them up.
Why not paste a GitHub token into the clone address?
The token would remain written in the repository settings in your account and would open everything that token is allowed to reach. A read-only deploy key is the safer choice.
What should I do with the key files on my computer?
After the import you have no further use for them. Delete site-key or store it somewhere safe. Never share the private key with anyone, our support team included.
How do I cut off access later?
Remove the key from Deploy keys on GitHub and from Manage SSH Keys in cPanel. Access ends at that moment.
Useful articles
- Git deployment on cPanel hosting: clone a GitHub repository and publish it with .cpanel.yml
- How to deploy a website from GitHub automatically: GitHub Actions with FTPS on hosting or rsync on a VPS
- Protecting API keys in cPanel apps and WordPress: safe storage and leak response
- SSH access on cPanel hosting: enabling it, Terminal and SSH clients