Cloning a private repository into cPanel requires the hosting account to authenticate to the repository provider. Use a dedicated deployment credential with the minimum repository access required, and keep the repository separate from the public website root where practical.
IN THIS ARTICLE
What you need before you begin
Confirm Git Version Control and authorised shell access are available. Obtain the repository’s SSH clone URL and trusted host-key fingerprint. Plan a read-only deploy key when the hosting server only needs to pull code.
01 Clone a private Git repository through cPanel
- Generate a dedicated key for outbound repository access under the hosting account using the provider-supported procedure. Keep its private half protected on the server.
- Add only the public key to the repository provider’s deploy-key or equivalent access settings, limited to the intended repository.
- Configure the account’s SSH client to use that identity for the specific repository host. Preserve existing SSH configuration and avoid a wildcard identity rule that affects unrelated hosts.
- Open Git Version Control > Create, enable cloning, enter the verified SSH URL and choose an empty permitted repository directory.
- Verify any host-key prompt, create the clone and inspect the resulting branch and commit. Deploy through a separate reviewed process rather than assuming cloning publishes the site.
Confirm the expected result
The repository should contain the intended project and be able to fetch authorised changes without an interactive password prompt. Confirm no credentials or .git data are publicly downloadable.
Troubleshoot unexpected results
If cloning fails, test the outbound identity and repository permission separately from inbound hosting SSH access. Never embed a username-password pair in a clone URL or bypass an unexpected host-key change.
Why can I log into hosting but not clone?
These are different authentication directions. Your laptop authenticates to hosting for inbound SSH, while the hosting server needs its own authorised identity to read the private repository.