Adding private git repo via cPanel
Asked Answered
P

16

36

I'm trying to add a private git repo onto cPanel but have ran into permission issues and not sure where I'm going wrong

I have generated the SSH keys in cPanel at the 'SSH Access' section. I then added the key onto the private repo in git at the 'Deploy keys' section.

But when I try to clone the repo on cPanel I get the error:

Error: “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

I'm trying to clone with SSH [email protected]:myusername/myrepo.git

Have I done something wrong or missed a step?

Parfleche answered 25/1, 2019 at 12:11 Comment(0)
D
18

CLONE GITHUB REPOSITORY TO CPANEL STEPS

steps 1. Cpanel -> SSH Access -> Generate New Key(without enter pasword)->after generated key go to under public key-> manage-> authorize (make authoize) -> back, now view/download-> copy key

Step 2. Go Github-> https://github.com// -> Settings(repository setting) ->Deploy Keys (rights side)-> add deploy key (give title,and add key)-> done

Step 3. Go to Cpanel -> Git™ Version Control -> clone url : [email protected]:/<private_repository_name>.git

 [email protected]:<user_name>/<repository_name>.git

-> give_repository_path

-> give_ repository_name

-> create

Step 4. manage repository from list-> Manage -> pull or deploy from Github -> Click on Update from Remote: works perfectly(any files edit or delete you fetch/pull from GitHub now)

Desdamonna answered 7/11, 2019 at 7:40 Comment(6)
I'm trying to clone a repository from GitLab and i keep getting the same error as the OP. What version of cPanel do you use? I have version 84.0.14 and it does not let me generate a key without entering a password. Do you know if a misconfigured firewall on the server could result in this error?Awning
I am using inmotion hosting, please ask hosting owner customer help they will give permissionDesdamonna
My problem was caused by the way cPanel generates ssl keys. When you create a key cPanel forces you to insert a passphrase. GitLab is not compatible with such a key apparently. The solution was to create the key on the local machine and import it to cPanel. Passphrases are for extra security when the key is stolen.Awning
Well i followed same, it said: Error: (XID 68e9nh) “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Edit: This was happening because i was adding this in my profile being unawared that it must be added in organization if the repository belongs to it (which is ofc not free)Bolo
Error: (XID zndzdp) “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.Swisher
Yeah no passpharse works. sweet.Healing
W
8

did you get to the bottom of this I was experiencing the same after removing the pass phrase from the key it worked

Washrag answered 12/2, 2019 at 16:31 Comment(8)
This fixed it! I generated a new ssh key without a passphrase and now I'm able to clone from within the cPanel interface. I recommend SSHing into your cPanel server then switch to the cPanel user and do some testing from the command line otherwise it's infuriating trying to debug form the cPanel Interface. Anyway, mark this as the answer! It fixes the issue.Jiggered
This fixes it! Just generate the SSH key via the command line without a passphrase. Don't forget to authorize it via cPanel and it works fine.Pageantry
Yes! Right, I did the same things and it's works charm!Desdamonna
steps 1. Cpanel -> SSH Access -> Generate New Key(without enter pasword)->after generated key go to under public key-> manage-> authorize -> back, now view/download-> copy keyDesdamonna
Step 2. Go Github-> github.com/<username>/<repository> -> Settings ->Deploy Keys (rights side)-> add deploy key-> doneDesdamonna
Step 3. Go to Cpanel -> Git™ Version Control -> clone url : [email protected]:<usernname>/<private repositoryname>.git -> give repository path -> give repository name -> createDesdamonna
Step 4. manage repository from list-> Manage -> pull or deploy from github : works perfectelyDesdamonna
Just thinking about isn't this will be dangerous to not use a passphrase, while generating the keys?Denys
F
7

After many hours i find this solution and it solved

My problem was caused by the way cPanel generates ssl keys. When you create a key cPanel, forced you to insert a passphrase. But GitLab is not compatible with such a key apparently.

The solution was to create the key on the local machine and import it to cPanel. Passphrases are for extra security when the key is stolen

as @vladmacovi said and i test it in my cpanel and its work

1- login to cpanel and gitlab

2- goto https://gitlab.com/profile/keys

3- Paste your public SSH key, which is usually contained in the file '~/.ssh/id_ed25519.pub' or '~/.ssh/id_rsa.pub' and begins with 'ssh-ed25519' or 'ssh-rsa'. Don't use your private SSH key.

4- create a key with this command:

ssh-keygen -t rsa -b 2048 -C "[email protected]"

5- this command create pub file and ppk file so you can open content of pub file.

6- goto cpanel /frontend/paper_lantern/version_control/index.html#/list/

create a new git repo then click on ssh then from: /frontend/paper_lantern/telnet/index.html

like this picture:

gitlab cpanel ci cd connect with ssh

7- cleck on import key from : /frontend/paper_lantern/telnet/keys/importkey.html

then paste your key

please dont type anything in Passphrase box

8- then click on import button then authorized it

9- configure git form like this picture

enter image description here

Frisch answered 21/7, 2020 at 18:43 Comment(0)
P
7

no SSH key WAY

My repository belongs to my organization and I followed Ghanshyam Nakiya answer but the Error was not fixed.

So I decide to Generate an access token to clone the git repository:

WARNING: this method has Some Risks like access-token leaks So do it at your own risk

  1. Open your personal profile settings on Github
  2. Find and open Developer Settings like the image below:

enter image description here

  1. Open Personal access tokens and generate a new token (with no time limit):

enter image description here

  1. Copy your token at the first Git Repo URL like this:

    https://[email protected]/YOUR-USERNAME/YOUR-REPOSITORY

  2. Now you can use this URL to put on Clone URL field on Cpanel and clone:

enter image description here

Parnassus answered 20/6, 2022 at 9:42 Comment(0)
S
5

I was following the Official cPanel tutorial and got stuck with the reported error code “128” when it ended: Permission denied (publickey) error when trying to clone a private repository from Github.

This blog helped me out https://gist.github.com/adamjohnson/5682757. Specially the part where it indicates that Github requires you to use SSH keys with id_rsa and id_rsa.pub names respectively.

Shannon answered 8/11, 2022 at 18:19 Comment(1)
If you edit your answer to also mention using no passphrase, then it should be the chosen answer, as it full solved it for me. i.e. 1) Don't change default names. 2) Don't use passphrases. Of course, this means one can only connect to a single private repository.Rok
D
3

Using Through github/ftp auto upload private repositoy to cpanel

GIthub Private repository with Cpanel Uploading step with one commit command from local pc repository to github and cpanel both

  1. create git repository in github (https://docs.github.com/en/get-started/quickstart/create-a-repo)

  2. after create an directory in local with github setup as following command

    git init
    git add .
    git commit -m "commit"
    git remote add origin
    git push
    

step 1. create FTP account into cpanel

step 2. in Github Go to your private repository on GitHub, click on SETTINGS, then click on SECRETS to add your FTP account username, password and server IP

step 3. On the SECRETS tab, click the NEW REPOSITORY SECRET BUTTON on the right hand side, to add a new secret

step 4. Add the details as follows (Using your own details)

The names should be FTP_SERVER, FTP_USERNAME,FTP_PASSWORD

and the values should be your own secret details respectively and click the ADD SECRET BUTTON

The next step is to create a GitHub action workflow; The GitHub actions take place on the GitHub server.

In your GitHub repo, click on ACTIONS

Step 5. Click NEW WORKFLOW, You can choose a workflow template but for the sake of this tutorial, we will be creating our own workflow.

Click on any template (I selected the first template), then edit the configuration (“yaml” configuration file)

Step 6. Change the file name to your own choice. (I changed mine to deployCpanel.yml), make sure it has the .yml file extension

step 7. Place the below configuration code in the file

   name: Publish Website to CPanel
   on:
     push:
        branches:
           - master
        jobs:
            FTP-Deploy-Action:
            name: FTP-Deploy-Action
            runs-on: ubuntu-latest
            steps:
                - uses: actions/[email protected]
                 with:
                 fetch-depth: 2
                   - name: FTP-Deploy-Action
                 uses: SamKirkland/[email protected]
                 with:
                    ftp-server: ${{ secrets.FTP_SERVER }}
                    ftp-username: ${{ secrets.FTP_USERNAME }}
                    ftp-password: ${{ secrets.FTP_PASSWORD }}

Make sure you change the branch where you want your codes to be deployed from, in my case I am deploying from master branch

Step 8 . Once you are done, click on START COMMIT button on the right hand side

This will automatically create a /.github/workflows/directory and places the configuration file in it.

Anytime you push your codes to the master branch, it automatically deploys to cPanel via your FTP account.

Desdamonna answered 24/2, 2022 at 6:50 Comment(2)
This is excellent, but when I pasted the configuration into GitHub, I'm getting an error on "jobs:" that it is an unknown key. Maybe it is out-of-date?Tittup
I think the script from Sam Kirkland may have been updated since this post was made: github.com/SamKirkland/FTP-Deploy-ActionTittup
A
2

Try this method. open Tarminal from Cpanel;

run below command to generate new ssh-key

ssh-keygen -t rsa -C "your github email"

Goto .ssh folder in your File Root, Edit id_rsa.pub and copy the content

login to github goto setting --> Deploy key --> add deploy keys --> paste the copied content.

and then run the below command

ssh -T [email protected]

if it return this Hi username/reponame You've successfully authenticated, but GitHub does not provide shell access. you're ready go.

Astrakhan answered 2/8, 2022 at 10:11 Comment(0)
D
2

No of the above answers worked for me, I still had the error:

Please make sure you have the correct access rights and the repository exists

By debugging with the command ssh -T [email protected], I had this error:

ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.

I coudl resolve it and fix my problem by regenerating a correct SSH certificated accepted by github with this command:

ssh-keygen -t ecdsa -b 521 -C "email@host" without passphrase

Doubletongued answered 3/10, 2022 at 18:12 Comment(0)
S
1

I have found an issue with the SSH key import within cPanel, when I import a private key via the cPanel SSH Key web interface it creates the file but includes the characters ^M as line breaks.

When I edited the file via SSH and copied the original key from my desktop the Git operation via cPanel worked straight away.

Solution

Edit the private key after import and ensure there are no line-ending or other stray characters.

Sounder answered 25/10, 2019 at 11:37 Comment(1)
Hurray! This actually worked! So copy paste SSH key texts directly is the way to go.Hardie
B
1

For me the problem remains, even doing all the steps of the different answers:

  • I created a publicKey with and without a password, either via Cpanel or locally
  • Keeps returning message "128" from the OP
Borderland answered 21/11, 2021 at 2:49 Comment(0)
C
0

got the same problem with @nodachi, already did all the previous solution given above.

the problem is the "private" repository in github. When i change my repo into "public", and then create repository again in my cpanel, it works.

i dont know why, the SSH access should be allowed to access the private repo on github, but it wont give the access.

Coriander answered 30/11, 2021 at 5:41 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Energize
A
0

Cpanel will not let you create key without password so you have to choices:

  1. Using ssh:
  • Step 1 create new ssh key using this command

ssh-keygen -t rsa -b 2048 -C "cpanel username"

  • Step 2 go to ssh management in your Cpanel then manage the newly generated key and authorize it.
  • Step 3 go to Github -> repo settings -> Deploy keys -> add you key and enjoy.
  1. You can import already generated key from you machine without using password and apply step 2 and 3
Aimee answered 17/2, 2022 at 18:36 Comment(0)
D
0

I had the same problem with the interface This guide is really complete and helped me fix it using the terminal

https://docs.cpanel.net/knowledge-base/web-services/guide-to-git-set-up-access-to-private-repositories/

*Previous: You must have enabled advanced>Terminal (shell?) Otherwise contact your hosting provider and asked for it enter image description here

*Create the ssh_key with NO passphrase just press Enter(replace repo with your repo name, username with your cpanel user and example.com with your cpanel main domain)

ssh-keygen -t rsa -f ~/.ssh/repo -b 4096 -C "[email protected]"

*Doesn't say so but neccesary: Authorize public ssh_key generated in SSH access > manage ssh keys > manage

enter image description here enter image description here

Click "authorize" enter image description here

*Copy public ssh key found in "view/download"

enter image description here

*I was using github so if you too, go to general settings

enter image description here enter image description here

enter image description here

Name it as you want too and paste the complete public ssh key

*Now test it (replace repo with your repo name)

ssh -i ~/.ssh/repo -T [email protected]

If a question (yes/no) about different fingerprints is raised write yes. This will add github to a known hosts file enter image description here

If everything's correct, confirm the greeting enter image description here

*I have multiple repositories (even if you currently don't, it's most likely to happen) so

domains > list domains enter image description here

click home icon enter image description here

show hidden folders at the top right hand corner settings>show hidden files enter image description here

enter image description here

inside .ssh folder, create a config file (extension isn't needed) enter image description here

enter image description here

enter image description here

Write this for each repo you need(again, replace "repo" with your repo name and "home/user" with your root path -in my case home/cpanelUser-)

Host github.com-repo
   Hostname github.com
   IdentityFile=/home/user/.ssh/repo

*Fiiiiinally, clone the repo (replace "repo" with your repo name and "user" with your GITHUB user this time)

git clone [email protected]:user/repo.git

Now, it should be done

enter image description here

Took me all afternoon and night :/ If you find how to auto deploy please comment

Dialyser answered 22/4, 2022 at 5:14 Comment(0)
D
0

In my case, while generating the ssh key from Cpanel's terminal I was putting the wrong URL for the site. In this command: ssh-keygen -t rsa -f ~/.ssh/repo -b 4096 -C "[email protected]" I was dropping the www.sitename.come and was writing sitename.com, that was my issue.

Donough answered 12/1, 2023 at 21:12 Comment(0)
D
0

This worked for me:

  1. from cpanel Terminal run this command:

ssh-keygen -t rsa -b 4096 -C ""

  1. from cpanel SSH Access: View/Download Public Keys named id_rsa

  2. https://github.com/username/private-repo/settings/keys click Add Deploy key

  3. back to cpanel Git Version Control click Create then Clone URL [email protected]:user-name/private-repo.git Repository Path where you like to clone on cpanel

Deutoplasm answered 22/2, 2023 at 22:46 Comment(0)
J
0

After trying various solutions, here's what finally worked for me:

  1. Accessing cPanel SSH Terminal:

    • Log in to cPanel via SSH terminal. You can do this either through your local terminal or the cPanel terminal. I prefer the local terminal for its speed and comfort.
  2. Checking OpenSSH Version:

    • Run ssh -V to check your cPanel's OpenSSH version. If it's below 7.2, you might encounter issues with GitHub due to recent changes. More details here.
  3. Generating Keys with New Algorithm:

    • For future-proofing, use the new ECDSA & ED25519 algorithm introduced by GitHub. See more Run:
      ssh-keygen -t ecdsa -b 521 -C “[email protected]
      Note: Don't use a passphrase.
  4. Filename Consideration:

    • GitHub expects the filenames to be "id_rsa" and "id_rsa.pub." Changing your generated keys to these names resolved my connection issues. Strange and confusing though, because the algorithm is ecdsa and not rsa. But its just a filename, i hope you understand
  5. Authorizing Public Key:

    • On cPanel, go to the SSH keys page and "Authorize" the public key.
  6. Adding Deploy Key on GitHub:

    • In your GitHub repository, navigate to Settings -> Deploy keys and add the generated key.
  7. Test ssh -T [email protected]. You'd see something like: Hi username/repo-name You've successfully authenticated, but GitHub does not provide shell access.

  8. Clone Repository in cPanel:

    • Now, try cloning your repository again from the cPanel page. It worked for both public/private repositories

I hope this straightforward guide works for you!

Jacquelynejacquelynn answered 1/12, 2023 at 23:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.