There was a problem loading the comments.

How to Connect Your cPanel Account to a Private GitHub Repository

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Introduction

This guide explains how to securely connect your cPanel hosting account to a private GitHub repository using SSH authentication.



Prerequisites

  • Access to your cPanel account
  • Git Version Control enabled
  • Access to your private GitHub repository



Step 1: Generate an SSH Key

Option A: Using cPanel Interface

  1. Login to cPanel
  2. Go to Security → SSH Access
  3. Click Manage SSH Keys
  4. Click Generate a New Key
  5. Enter:
    • Key Name: repo
    • Key Type: RSA
    • Key Size: 4096
  6. Click Generate Key


Option B: Using Terminal

ssh-keygen -t rsa -f ~/.ssh/repo -b 4096 -C "git@mydomain.com"


Press Enter three times when prompted.

 

Step 2: Authorize the SSH Key

  1. Go to SSH Access → Manage SSH Keys
  2. Click Manage
  3. Click Authorize



Step 3: Configure SSH

  1. Open cPanel → File Manager
  2. Navigate to the .ssh directory (enable hidden files)
  3. Create a file named config
Host github.com
    IdentityFile ~/.ssh/repo


Replace repo with your key name if different.

chmod 600 ~/.ssh/config
chmod 600 ~/.ssh/repo
chmod 644 ~/.ssh/repo.pub



Step 4: Copy the Public Key

cat ~/.ssh/repo.pub


Copy the full output.



Step 5: Add the SSH Key to GitHub

  1. Login to GitHub
  2. Navigate to your private repository
  3. Click your profile icon (top-right) → Settings
  4. Click SSH and GPG keys
  5. Click New SSH key
  6. Paste your key and save



Step 6: Clone Repository in cPanel

  1. Go to cPanel → Git Version Control
  2. Click Create
  3. Enter:
git@github.com:username/repository.git


Select a repository path and click Create.


Optional: Auto Deployment

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/USERNAME/public_html/
    - /bin/cp -R * $DEPLOYPATH



Troubleshooting

  • Permission denied: SSH key not added or incorrect permissions
  • Repository not found: Incorrect URL or access issue
  • Clone failed: Check SSH config and key setup

Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© Indichosts.net