To clone a private repository, SSH access is required, and additional steps need to be performed. In this tutorial, GitHub is used as an example, but these steps are similar for other private repository hosts. Ensure you have Shell Access enabled in cPanel, which is available under the Terminal interface.


Steps to Set Up Access to Private Repositories

Step 1: Generate an SSH Key

If you don’t already have an SSH key configured, generate one by running the following command:

bash
 
ssh-keygen -t rsa -b 4096 -C "username@example"
  • Replace username with your cPanel account username and example with your domain name.
  • When prompted to enter a passphrase, simply press Enter without entering anything.

Step 2: Verify the Generated SSH Key

To confirm the SSH key has been correctly generated, execute:

bash
 
cat ~/.ssh/id_rsa.pub
  • If the output includes a valid SSH key (e.g., ssh-rsa AAAAB3Nza...), your key is correctly generated.
  • If the output shows an error (e.g., No such file or directory), ensure you’ve entered the correct path or repeat Step 1.

Step 3: Register Your SSH Key with the Private Repository Host

For GitHub:

  1. Log in to your GitHub account.

  2. Go to your private repository.

  3. Click Settings in the top right corner.

  4. In the left menu, click Deploy Keys.

  5. Click Add deploy key.

  6. Enter the following details:

    • Title: A display name for the key.
    • Key: Paste the entire SSH key from Step 2.
    • Allow write access: Tick this box if you want to push code from cPanel to GitHub.
  7. Click Add key to save.

For other hosts:
Check the documentation or contact the repository host for details on registering an SSH key.


Step 4: Test the SSH Key

Run the following command to test your SSH key (replace example.com with your repository host):

bash
 

Step 5: Clone the Repository

Once the SSH key is configured, use the following command to clone the repository (replace the example URL with your private repository’s clone URL):

bash
 
git clone [email protected]:MyStuff/private-repository.git

Important Notes

  • Ensure you have the Shell Access feature enabled in cPanel.
  • cPanel’s Terminal interface provides command-line access for executing the required commands.
  • For ssh:// clone URLs, cPanel verifies the remote host’s public SSH keys.

By following these steps, you can easily set up access and clone privately-hosted repositories using Git in cPanel. If you encounter issues, consult the repository host’s documentation or cPanel’s Git Version Control documentation.

Byla tato odpověď nápomocná? 90 Uživatelům pomohlo (361 Hlasů)