Guide to Git — Set Up Access to Private Repositories

This article explains how to configure SSH access so you can connect your cPanel account to private Git repositories. It covers generating SSH keys, creating SSH configuration files, registering keys with GitHub or other hosts, testing access, and cloning repositories using secure authentication.

SSH KeysPrivate Git RepositoriescPanel Git

~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 name
  • username → your cPanel username
  • example.com → your cPanel domain

Example:


ssh-keygen -t rsa -f ~/.ssh/testing -b 4096 -C "[email protected]"

Warnings:

  • -t sets the key type.
  • -f sets the key filename (public key = same name + .pub).
  • -b sets key size.
  • -C adds 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:


  1. Log in to GitHub.
  2. Open your private repository.
  3. Go to Settings.
  4. Select Deploy keys.
  5. Click Add deploy key.
  6. Enter a title.
  7. Paste the contents of your public key file (e.g., ~/.ssh/testing.pub).
  8. Enable Allow write access if you want to push code.
  9. 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