Private GitHub repository in cPanel: deploy key
A private GitHub repository cannot be cloned with a plain https link. The reliable way is an SSH deploy key: a separate key that gives read-only access to a single repository.
Git Version Control in cPanel connects to GitHub on its own and cannot type a key passphrase. The key must therefore have no passphrase. The "Generate a New Key" form in cPanel requires a passphrase, so create the key on your computer and import it, or ask support.
1. Create the key on your computer
On Windows (PowerShell), macOS or Linux run the command and press Enter twice when asked for a passphrase:
ssh-keygen -t ed25519 -C "github_deploy" -f github_deploy -N ""You get two files: github_deploy (private key) and github_deploy.pub (public key).
2. Import the key into cPanel
- Open "SSH Access" (Security group) and click "Manage SSH Keys".
- Click "Import Key".
- Enter
github_deployas the key name. - Paste the whole content of
github_deployinto the private key field and leave the passphrase empty. - Paste the content of
github_deploy.pubinto the public key field and click "Import".
If creating the key yourself is inconvenient, open a ticket: "create a passphrase-less key github_deploy for Git". We will create it in your account and send you the public part. The private key is never sent to anyone.
3. Tell Git which key to use for GitHub
Open "File Manager", turn on hidden files (Settings - "Show Hidden Files"), open the .ssh folder and create a file named config with this text:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_deploy
IdentitiesOnly yes4. Add the public key to GitHub
- Open the repository on GitHub - Settings - Deploy keys - Add deploy key.
- Title: any name, for example "hosting".
- Key: the content of
github_deploy.pub(one line). - Leave "Allow write access" unchecked: read access is enough for hosting.
- Click "Add key".
5. Clone the repository
In Git Version Control click "Create", enter the SSH address of the repository in "Clone URL", for example git@github.com:user/repo.git, choose a folder and click "Create". No password is asked.
Scheduled updates
To update the site from GitHub automatically, without GitHub Actions, add a job in Cron Jobs, for example every 15 minutes:
cd $HOME/repositories/repo && git pull --ff-onlyTo copy files into the site folder, use a .cpanel.yml file as described in Git in cPanel.
If it does not work
- "Permission denied (publickey)": the public key is not in Deploy keys of this repository, or
confignames a different key. - Cloning hangs or asks for a password: the key has a passphrase; create one without it.
- "Repository not found": wrong address, or the key was added to another repository.