How to Connect CPanel with GitHub Using SSH (Step-by-Step Guide)

How to Connect CPanel with GitHub Using SSH (Step-by-Step Guide)

If you want to deploy your GitHub project to CPanel using SSH, follow these simple steps.


✅ Step 1: Login to Your Server via SSH

First, log in to your server using SSH.

1️⃣ Open Terminal (Mac/Linux) or Git Bash (Windows)
2️⃣ Run this command to log in:

bash
ssh your-cpanel-username@your-server-ip

3️⃣ Enter your server password when prompted.


✅ Step 2: Generate an SSH Key

Now, create an SSH key for authentication.

1️⃣ Run this command:

bash
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"

2️⃣ Press Enter to save the key in the default location (~/.ssh/id_rsa).
3️⃣ Press Enter again to skip the passphrase.

Your SSH key is now generated! ✅


✅ Step 3: Approve SSH Key in CPanel

Now, add the SSH key to your CPanel Authentication Keys.

1️⃣ Login to CPanel
2️⃣ Go to SSH Access > Manage SSH Keys
3️⃣ Click Import Key
4️⃣ Copy the Public Key from your server:

bash
cat ~/.ssh/id_rsa.pub

5️⃣ Paste the key into CPanel’s “Public Key” field and click Authorize Key.

✅ Your SSH Key is now approved!


✅ Step 4: Test the SSH Connection

To check if your server is successfully connected to GitHub, run:

bash
ssh -T git@github.com

If successful, you’ll see a message:

vbnet
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

✅ This means your server is connected to GitHub via SSH!


✅ Step 5: Add Your GitHub Repository to CPanel

Now, add your GitHub repository to CPanel Git Version Control.

1️⃣ Go to CPanel > Git Version Control
2️⃣ Click Create
3️⃣ Enter your Git Repository SSH URL (Example: git@github.com:your-username/your-repo.git)
4️⃣ Select the deployment directory
5️⃣ Click Create


✅ Step 6: Deploy Your Project

Once the repository is added, CPanel will automatically clone it to your server.

To manually pull changes, go to CPanel > Git Version Control > Manage and click Pull or Deploy.


Done! Now You Have GitHub Auto Deployment on CPanel via SSH!

Now, every time you push updates to GitHub, you can easily pull them to CPanel without entering passwords!

If you face any issues, let me know!

Related Posts