Scroll to top
© 2022, Empty Code | All Rights Reserved

Cloning a Private Git Repository in cPanel


Rahul Kumar Sharma - September 30, 2022 - 0 comments

To clone a private repository, you must use an SSH key pair and the SSH protocol in the clone URL. If you try to clone a private repository using Git Version Control which is available in cPanel, it will return an error message following:

Error: (XID xna4yx) “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: fatal: could not read Username for 'https://github.com': No such device or address

Requirements

  • Must have Git Version Control Option in cPanel. Files -> Git Version Control
  • Must have Terminal Access Advanced -> Terminal

If your cPanel doesn’t have an enabled feature, You can request your hosting provider to enable it.

Steps

Create an SSH Key Pair

At first, you are required to create an SSH Key Pair without a password and that can be generated from the terminal.

  1. Go to Terminal and type ssh-keygen -t rsa
  2. Then, It will ask to Enter the file in which to save the key:
  3. Click Enter
  4. It will ask for the passphrase Enter passphrase (empty for no passphrase):
  5. Click Enter
  6. Enter same passphrase again:
  7. Click Enter
  8. Now, You will see the successful message:
    • Your identification has been saved in xxxxxxx
    • Your public key has been saved in xxxxxxx
    • The key fingerprint is: xxxxxxx
  9. Copy the public key from the saved path.
  10. And you are done 🙂
Add the public key to the Git provider
  1. Open your repository in Git Provider.
  2. Go to Settings
  3. Check for the Deploy keys option.
  4. Click Add Deploy key
  5. Add a Random title and paste the public key which was copied from cPanel.
  6. Click on Add key
How to add an SSH key to GitHub?
Test the Connection

Go to Advanced -> Terminal and type the following command:

  • GitHub: ssh -vT git@github.com
  • GitLab: ssh -vT git@gitlab.com
  • Bitbucket: ssh -vT git@bitbucket.org

Once you verify that the SSH connection is working, you are ready to clone the private repository using the ssh:// protocol.

Clone the Private Repository
  • Go to Git Version Control
  • Click Create
  • In the Clone URL text box, type the URL of the repository to clone
  • Type the path to the document root of the site in the Repository Path text box
  • Type the name of the Repository in the Repository Name text box
  • Click Create

Post a Comment

Your email address will not be published. Required fields are marked *