skip to Main Content

I have multiple private repos in Github. When I try to setup a second cpanel repository (using the prescribed Git Version Control and SSH key/pair configuration instructions), the second repository fails with the dreaded 128 error:

  • Error: “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: Permission denied, please try again. Permission denied, please try again.

I have two subdomains on my hosting account (think of them as ‘test’ and ‘prod’), each pointing to its own subfolder (in cpanel File Manager) and each one has its own private repository in Github. The first subdomain (test) works great – Pull Requests feed through from Github to my website successfully every time. But when I try to setup a second cpanel Repository, the above error occurs – can’t seem to shake this one.

I verified the key pairs are properly configured (cat ~/.ssh/id_rsa.pub and cat ~/.ssh/id_rsa3.pub), and found them properly loaded in the .ssh/ folder of cpanel. I even triple-checked my Github repos to make sure they each had their own Deploy keys (public SSH key from cpanel).

Any guidance would be greatly appreciated!

Thanks much!!
Dan

4

Answers


  1. Git Version Control page showing 128 errorThe fact the second key has not a default name means it would require a ~/.ssh/config file indeed, as you mentioned.
    But the CPanel SSH documentation does not clearly mention it does use said config file (even though it is mentioned in this tutorial).

    Check first if this is an issue with a passphrase-protected provate key, as mentioned here.
    Or that the private key was imported in CPanel with the wrong eol (end of line) character.

    Login or Signup to reply.
  2. As per comment chain on VonC’s answer you cannot use an alias from ssh config when creating a Git repo in cPanel. Which makes life hard.

    But for some reason you can when running the equivalent command via the API. So make an API call instead. The API endpoint we want is /VersionControl/create, documented at api.docs.cpanel.net/openapi/cpanel/operation/VersionControl::create.

    The quickest way to make the API call is to simply plug a URL like the below straight into the browser.

    https://hostname.example.com:2083/cpsess##########/execute/VersionControl/create?type=git&name=example&repository_root=/home/user/public_html/example&source_repository={"remote_name":"origin","url":"github_alias:github-user/yourreponame.git"}

    Replace cpsess########## with whatever key you’re assigned when logging into cPanel interface.

    You’d then have a ssh config looking a little something like this:

    Host github_alias
      Hostname github.com
      User git
      IdentityFile ~/.ssh/github_key1
      Port 22
    Host github_alias2
      Hostname github.com
      User git
      IdentityFile ~/.ssh/github_key2
      Port 22
    
    Login or Signup to reply.
  3. open Terminal in Cpanel account

    ssh-keygen -t rsa -b 4096 -c "[email protected]"
    

    it will ask you to give file name to save the key ,give the full path :

    /home/usernameofcpanel/.ssh/filename_key

    do not enter passphasrse – pree enter

    It will generete SSH key

    in Cpanel you can open SSHKEy section – you will see private and public key with the name filename_key

    Authrise the key from cpanel

    Add this key in Github – https://github.com/youraccount/Repositoryname/settings

    you can go to settings from clicking on repository in Security section go to Deploy key –

    click on Add Deploy Key

    Add the Key details – Copy public key details from Cpanel SSH Key – for filename_key

    and provdie name and copu the public key

    chcek Allow Write acess – if you wnat to write to Github from cpanel

    once done come back to Cpanel

    go to .ssh folder open config file

    add the following to config and save the file

    Host [Repositoryname].github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/filename_key
      IdentitiesOnly yes
    
    Host [Repositoryname2].github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/filename2_key
      IdentitiesOnly yes
    

    Now open Terminal from Cpanel

    ssh -Tv [email protected]
    

    it should give the following message if successfully connected
    Hi [Gitowneraccountname]/[Repositoryname] you have successfully authenticated,but GitHub doesn’t provide shell access.

    you are now ready to connect the GitHub to gitversion

    from your GitHub repository copy the clone URL of ssh

    [email protected]:[Gitowneraccountname]/[Repositoryname].git

    go to Gitversion inside cpanel

    click on Create

    copy the clone URL to clone text box

    [email protected]:[Gitowneraccountname]/repository.git change the url to below

    git@[Repositoryname].github.com:[Gitowneraccountname]/repository.git

    add the subdomain as [Repositoryname] and you will be able to get the cpanel gitversion working with multiple git repositories

    Login or Signup to reply.
  4. This exact error is usually caused by the ~/.ssh/config file.
    So you should definitely revisit the configuration in that file.

    You should change the texts to this

    Host github.com
        IdentityFile ~/.ssh/{private_ssh_key_name}
    

    To actually read more on this, check these documentation and article published by cpanel themselves out.

    This is the documentation that explains the step by step processes to set up your ssh keys for single and multiple private repositories.

    This is the link to the article that helped me solve the error.

    Emphasis on option 2, number 11

    "NOTE: If you want to use this private key when connecting to any remote host via SSH, you may use an asterisk character as the Host instead of a specific domain name: *
    Otherwise, use the domain name of your remote Git repository provider."

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search