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

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue