Back to Blog

Integrating cPanel with GitHub

Vignesh Saravanan · Nov 24, 2024

GitHubcPanelDevOpsSSH

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.

terminal
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:

terminal
touch ~/.ssh/config

Step 3: Secure the Config File

Restrict the file permissions so only your user can read and write it:

terminal
chmod 0600 ~/.ssh/config

Step 4: Configure SSH for GitHub

Edit ~/.ssh/config and tell SSH which key to use when talking to GitHub:

~/.ssh/config
Host github.com
     IdentityFile ~/.ssh/stagingserver

Step 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.

terminal
cat ~/.ssh/stagingserver.pub

Step 6: Verify the Connection

Confirm the setup works with an SSH test against GitHub:

terminal
ssh -i ~/.ssh/stagingserver -T git@github.com

If 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.
⚠️ Security note: always keep your private key secure and never expose it in shared environments.