How to resolve cPanel Git error code 128- ‘Permission Denied’ issue

June 29, 2024 / How-to Guide

Encountering Git Error Code 128: ‘Permission Denied’ when trying to push or pull repositories on a cPanel hosting environment is typically caused by permissions issues either in the Git repository or the user account trying to access it. Although this can be frustrating, several solutions can fix the error.

Potential Causes –

There are several common reasons for this error in cPanel:

  1. Improper Repository URL: Your script may be using the wrong Git repository URL.
  2. SSH Key Issues: The SSH key defined on your local environment may differ from the authorised key on the server.
  3. Repository Ownership: The ownership and permissions on the Git repository may not be set properly in cPanel.
  4. SELinux Issues: If SELinux is enabled and misconfigured, it could block Git operations due to incorrect security policies.

Troubleshooting Steps:

Here is a summary of how you can identify and fix Error 128 in cPanel:

  1. Verify Repository URL: Ensure that the repository URL provided as the origin is correct. The URL should be in the format
    ssh://[email protected]/path/to/repo.git.
  2. Check SSH Key: Confirm that the SSH key set in your local environment matches the public key listed in the SSH Access section of the cPanel interface. You can also make the key importable via the terminal.
  3. Check Repository Ownership: Log in to your server via SSH and navigate to the Git repository folder (e.g., /home/username/repo.git). Use ls -al to check the ownership. If you don’t own the folder, use chown to change ownership to your cPanel username.
  4. Set Repository Permissions: Use ‘ls -al’ to check the permissions on the Git repository folder. Ensure the folder and its contents have permissions set to 0755 or 0700. Use ‘chmod’ to set the desired permissions recursively.
  5. Disable SELinux: SELinux can sometimes interfere with Git operations. Try temporarily disabling it to see if that resolves the issue:
    sudo setenforce 0
    If disabling SELinux works, adjust the SELinux policies to allow the necessary Git operations properly.
  6. Restart Git Server: Once appropriate changes or corrections have been made to ownership, permissions, or SELinux, restart the Git server process in cPanel to apply the changes.
  7. Open Support Ticket: If the problem persists after trying all the above steps, open a support ticket with your hosting service provider for further assistance.

Additional Tips:

  • Confirm you are running the latest version of Git locally and that your cPanel server also has the latest Git version installed.
  • Check the Git logs on your cPanel server (usually /var/log/git) for any extra error messages that could provide more context.
  • Create a new test repository to isolate whether the issue is specific to a single repo or a broader configuration problem.
  • If using Git over HTTPS, ensure you have followed the right public key setup process instead of using SSH URLs.

By methodically checking repository URLs, SSH keys, repository permissions, and server configurations, you should be able to pinpoint and resolve the root cause of the Error Code 128 ‘Permission Denied’ issue with Git on your cPanel server.

 

Spread the love