Integrating cPanel with GitHub
Vignesh Saravanan · Nov 24, 2024
Deploying code to a cPanel server doesn't have to mean dragging files through a file manager or FTP client. By linking your server to GitHub over SSH, you can pull changes straight from your repository — faster deployments, proper version control, and no credentials floating around. Here's the step-by-step setup.
Step 1: Generate an SSH Key
On your cPanel server (via Terminal or SSH access), generate a dedicated key pair for the connection. Replace the comment with your GitHub username and rename the key file if you like.
ssh-keygen -t rsa -f ~/.ssh/stagingserver -b 4096 -C "VigneshSaravanan0026"Step 2: Create the SSH Config File
If it doesn't already exist, create an SSH config file:
touch ~/.ssh/configStep 3: Secure the Config File
Restrict the file permissions so only your user can read and write it:
chmod 0600 ~/.ssh/configStep 4: Configure SSH for GitHub
Edit ~/.ssh/config and tell SSH which key to use when talking to GitHub:
Host github.com
IdentityFile ~/.ssh/stagingserverStep 5: Add the Deploy Key on GitHub
Copy the contents of the public key file ~/.ssh/stagingserver.pub and add it to your repository under Settings → Deploy Keys → Add deploy key.
cat ~/.ssh/stagingserver.pubStep 6: Verify the Connection
Confirm the setup works with an SSH test against GitHub:
ssh -i ~/.ssh/stagingserver -T git@github.comIf everything is configured correctly, GitHub greets you with a "successfully authenticated" message. You can now clone and pull your repository directly from cPanel's Git Version Control.
Why Bother?
- Version control: update your server straight from the repository — no manual intervention.
- Efficiency: eliminates manual file uploads and out-of-sync deployments.
- Security: deploy keys give a repo-scoped, secure connection instead of shared passwords.