~3 min read • Updated Feb 21, 2026
1. Overview
This guide explains how to set up SSH access so you can clone a local cPanel-hosted repository to a remote private repository. Before cloning or pushing code, you must generate SSH keys and register them with the remote repository host.
Important: This tutorial uses GitHub as an example, but the steps are similar for most private Git hosts. SSH Access & Terminal features must be enabled for your cPanel account.
2. Set Up SSH Access to Private Repositories
2.1 Connect to Your Server via SSH or cPanel Terminal
Use SSH or the cPanel Terminal to access your account. After connecting, run all commands in your terminal environment.
3. Generate an SSH Key
Run the following command to generate a new SSH key pair:
ssh-keygen -t rsa -f ~/.ssh/repo -b 4096 -C "[email protected]"
Replace:
repo→ repository nameusername→ your cPanel usernameexample.com→ your cPanel domain
Example:
ssh-keygen -t rsa -f ~/.ssh/testing -b 4096 -C "[email protected]"
Warnings:
-tsets the key type.-fsets the key filename (public key = same name +.pub).-bsets key size.-Cadds a comment (usually your email).
When prompted for a passphrase, press Enter and leave it empty.
4. Create the SSH Configuration File
Steps:
touch ~/.ssh/config
chmod 0600 ~/.ssh/config
chown cpanelusername:cpanelusername ~/.ssh/config
Edit the file and add:
Host remote-git-repo-domain.tld
IdentityFile ~/.ssh/testing
Notes:
- You may use
*as the host to apply this key to all SSH connections. - Use the exact path to the private key you generated.
5. Register Your SSH Key with the Private Repository Host
GitHub Example:
- Log in to GitHub.
- Open your private repository.
- Go to Settings.
- Select Deploy keys.
- Click Add deploy key.
- Enter a title.
- Paste the contents of your public key file (e.g.,
~/.ssh/testing.pub). - Enable Allow write access if you want to push code.
- Click Add key.
Note: Some hosts (e.g., Bitbucket) do not allow write access for deploy keys.
6. Test the SSH Key
Run:
ssh -i ~/.ssh/repo -T [email protected]
Example:
ssh -i ~/.ssh/testing -T [email protected]
7. Set Up Access to Multiple Repositories
Create a separate SSH key for each repository, then configure ~/.ssh/config like this:
Host github.com-testing
Hostname github.com
IdentityFile=/home/cptest/.ssh/testing
Host github.com-testing2
Hostname github.com
IdentityFile=/home/cptest/.ssh/testing2
8. Clone a Repository (Single Repository)
git clone [email protected]:username/repo.git
Example:
git clone [email protected]:cptest/testing.git
9. Clone a Repository (Multiple Repositories)
git clone git@Host:username/repo.git
Example:
git clone [email protected]:cptest/testing2.git
Conclusion
By following these steps, you can securely connect your cPanel account to private Git repositories, manage multiple SSH keys, and clone or push code safely. This setup is essential for private development workflows and automated deployments.
Written & researched by Dr. Shahin Siami