2

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

Hugo y
  • 1,421
  • 10
  • 20
dhoegl
  • 33
  • 3
  • Further adding to this... I setup a .ssh/config file containing IdentityFile mapping of each SSH key corresponding to each Github repo. Then used ssh -T github.com-tec (the 'github.com-tec' suffix is an alias to the corresponding SSH key in the config file) to try and connect to my repo from cpanel Terminal. CONNECTED! However... when attempting to try and use this alias to create a new cpanel repository in Git Version Control, it didn't recognize the alias. Back to the drawing board. – dhoegl Jan 27 '21 at 03:45

4 Answers4

2

open Terminal in Cpanel account

ssh-keygen -t rsa -b 4096 -c "yourcpanalaccount@yourdomain.com"

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 git@repositoryname.github.com

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

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

go to Gitversion inside cpanel

click on Create

copy the clone URL to clone text box

git@github.com:[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

Xcode
  • 21
  • 3
0

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.

dhoegl
  • 33
  • 3
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the reply! I sure wish it were that simple to fix. Passphrase is blank, did not import the keys (used native cpanel UI to create them). Any other thoughts will help greatly. – dhoegl Jan 27 '21 at 20:59
  • @dhoegl Can you share a screenshot illustrating the issue? Are you using the right URL (one with the config file referencing the right private key)? – VonC Jan 27 '21 at 21:03
  • Hi @VonC the issue (error) occurs when trying to create a new cpanel Repository on the Git Version Control page (I have screenshots but need to upload somewhere first and link them in a follow-up comment - don't think I can embed in this comment, right?). I'm not sure which URL you are referring to... The config file is located in ~/.ssh where I believe it's supposed to be. Would a screenshot of the config file be helpful as well? – dhoegl Jan 27 '21 at 22:50
  • Just added a screenshot to my initial post – dhoegl Jan 27 '21 at 22:56
  • @dhoegl OK, I will have a look tomorrow. – VonC Jan 27 '21 at 23:21
  • @dhoegl The URL I mentioned is the "Clone URL" one: a default `git@github.com:` one will rely on a default `~/.ssh/id_rsa` private key. If you need to use a second one, the URL should be `xxx:...`, with `xxx` a `Host` entry in your `~/.ssh/config` file. – VonC Jan 28 '21 at 17:53
  • Thank you @VonC for trying to help. Unfortunately using my host entry name (from .ssh/config) was unsuccessful - syntax doesn't allow anything other than git@github.com.... I also contacted GoDaddy (my hosting service where cpanel resides), and they were also stumped. I have decided to revert back to a Public repo on Github for now. Works fine without SSH. Unfortunately I don't have time to continue troubleshooting, so will come back to this at another time. Thank you again!! – dhoegl Jan 28 '21 at 19:36
  • @dhoegl Right, I see the cPanel field mandates a certain format! Can you try, for a quick last check, `ssh//xxx//`? – VonC Jan 28 '21 at 19:40
  • No luck sorry. I even tried a half-dozen different derivations of your suggestion. One item of note, starting the url with 'ssh//.' is not allowed - according to the tool-tip on the field, All clone URLs must begin with the http://, https://, ssh://, or git:// protocols or begin with a username and domain. Another interesting point... the xxx mentioned above needs to be a valid IP address or FQDN. Tried ssh://xxx// where xxx=the Host entry in .ssh/config - plus several other variations. No such luck :( – dhoegl Jan 28 '21 at 23:35
  • @dhoegl Wait, I am confused: you say "according to the tool-tip on the field, All clone URLs must begin with the http://, https://, `ssh://`, or git:// protocols", and "starting the url with '`ssh//:`' is not allowed", so is ssh:// allowed or not? The tool-tip says it is allowed. – VonC Jan 29 '21 at 07:32
  • @dhoegl I realize I forgot the ':' in my previous suggestion. It should be: `ssh://xxx//`. That way, you can force ssh to consider your `~/.ssh/config` `xxx` `Host` entry. – VonC Jan 29 '21 at 07:33
0

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
James Jones
  • 3,850
  • 5
  • 25
  • 44
0

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."

Leksyking
  • 322
  • 3
  • 5