Cloning A Private Github Repo To A cPanel Server

Private repos require SSH access, you must perform additional steps in order to clone a privately-hosted remote repository.

You can use cPanel's Terminal interface (cPanel >> Home >> Advanced >> Terminal) to access the command line from within the cPanel interface.

You can also your system's Terminal or any tool that allows you to access the cPanel server via SSH.

 

 

1. Generate An SSH Key

If you have not already configured one, run the following command to generate an SSH key:

ssh-keygen -t rsa -b 4096 -C "username@example"

In this example, "username" represents the cPanel account username and "example" represents the domain name.

After you run this command, the system will prompt you to enter a passphrase.

Do not enter a passphrase.

Press Enter to continue.

 

 

2. Verify That You Generated The Ssh Key Correctly

To confirm that the key exists and is in the correct location, run the following command:

cat ~/.ssh/id_rsa.pub

 

 

3. Register Your SSH Key With The Private Repository Host

For information about how to register your SSH key with another private repository host (Bitbucket, GitLab, etc), consult that host's website or documentation.

Some repository hosts, such as Bitbucket, do not allow you to configure write access for your access keys.

To register an SSH key with GitHub, perform the following steps:

 

 

  1. Log in to your GitHub account.
  2. Navigate to your private repository.
  3. In the top right corner of the page, click Settings. A new page will appear.
  4. In the left side menu, click Deploy keys. A new page will appear.
  5. In the top right corner of the page, click Add deploy key. A new page will appear.
  6. Enter your SSH key data:
  7. In the Title text box, enter a display name for the key.
  8. In the Key text box, paste the entire SSH key. If you want to push code from your cPanel account to your GitHub account, select the "Allow write access" checkbox. Do note that if you do not select this checkbox, you can only deploy changes from your GitHub repository to the cPanel-hosted repository.
  9. Click Add key.

 

 

4. Test Out The SSH Key

To test your SSH key, run the following command.

ssh -T git@example.com

where example.com represents the private repository's host - e.g ssh -T git@github.com.

 

 

5. Clone The Private Repo

To clone the repository, run the following command on the cPanel account, where "git clone git@example.com:$name/private-repo.git" represents the private repository's clone URL:

git clone git@example.com:$name/private-repo.git

If you see Error: The WebSocket handshake failed at ... when you access cPanel's Terminal interface (cPanel >> Home >> Advanced >> Terminal), recheck your connect.

If you are using VPN, disconnect and use your normal internet connection.

  • Github, SSH
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Common Git Commands You Can Use with cPanel's Git Version Control

You can access all of Git™'s functionality via the command line. This document lists common...

How To Create A Repository With cPanel Git Version Control

You won't be able to use all the its features if you are using our FREE cPanel account since...

How To Manage Repositories With cPanel Git Version Control

Click Manage to modify or deploy repositories. Click Basic Information to view repository...

How To Set Up Your Git In cPanel

Git’s extremely useful when you configure it to transfer content between a local and remote...

How You Can Host Git Repositories on Your cPanel Account

cPanel is working to release version control using Gitweb that ships with Git and will be either...