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
- Login to cPanel
- Go to Security → SSH Access
- Click Manage SSH Keys
- Click Generate a New Key
- Enter:
- Key Name: repo
- Key Type: RSA
- Key Size: 4096
- 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
- Go to SSH Access → Manage SSH Keys
- Click Manage
- Click Authorize
Step 3: Configure SSH
- Open cPanel → File Manager
- Navigate to the .ssh directory (enable hidden files)
- 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
- Login to GitHub
- Navigate to your private repository
- Click your profile icon (top-right) → Settings
- Click SSH and GPG keys
- Click New SSH key
- Paste your key and save
Step 6: Clone Repository in cPanel
- Go to cPanel → Git Version Control
- Click Create
- 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