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,305
  • 9
  • 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

2 Answers2

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,129,465
  • 480
  • 4,036
  • 4,755
  • 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,732
  • 5
  • 23
  • 44