Private GitHub repository on cPanel hosting: setting up a read-only deploy key (ed25519)

Print
  • 0

In 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

PieceFile name in this guideWhere it ends up
Public keysite-key.pubGitHub, in the repository settings
Private keysite-keycPanel only, imported as id_ed25519
SSH clone addressgit@github.com:username/site.gitThe 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

  1. In the repository on GitHub, go to Settings and choose Deploy keys, then Add deploy key.
  2. Give it a Title you will recognise later, such as "cPanel TopHost".
  3. Open site-key.pub in Notepad or another plain text editor, copy everything and paste it into Key.
  4. Make sure Allow write access stays empty, then confirm with Add key.

Part 3. Hand the private key to cPanel

  1. In cPanel, open SSH Access from the Security group and go to Manage SSH Keys.
  2. Choose Import Key. As the name, type id_ed25519 and nothing else: Git looks for that exact file name and ignores keys called differently.
  3. Paste the whole content of site-key into the private key box. The lines that begin and end the key must be included.
  4. 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 seeLikely 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 foundThere is a typo in the address, or the key was registered on a different repository.
Key is already in use on GitHubGitHub accepts a deploy key on one repository only. Generate a fresh pair for each repository.
Everything looks right, cloning still failsContact 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

Was this answer helpful?

Need help?

Write to us in the chat, by e-mail or open a ticket from your account.

Live chatOpen the chat Call us+373 795-800-80 Write to ussupport@tophost.md
Copyright © 2026 TopHost.MD. All Rights Reserved.