'Adding private git repo via cPanel
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?
Solution 1:[1]
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)
Solution 2:[2]
did you get to the bottom of this I was experiencing the same after removing the pass phrase from the key it worked
Solution 3:[3]
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:
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
Solution 4:[4]
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.
Solution 5:[5]
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
Solution 6:[6]
Using 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
create git repository in github (https://docs.github.com/en/get-started/quickstart/create-a-repo)
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.
Solution 7:[7]
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.
Solution 8:[8]
Cpanel will not let you create key without password so you have to choices:
- 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.
- You can import already generated key from you machine without using password and apply step 2 and 3
Solution 9:[9]
I had the same problem with the interface This guide is really complete and helped me fix it using the terminal
*Previous: You must have enabled advanced>Terminal (shell?) Otherwise contact your hosting provider and asked for it
*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
*Copy public ssh key found in "view/download"
*I was using github so if you too, go to general settings
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
If everything's correct, confirm the greeting
*I have multiple repositories (even if you currently don't, it's most likely to happen) so
show hidden folders at the top right hand corner settings>show hidden files
inside .ssh folder, create a config file (extension isn't needed)
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
Took me all afternoon and night :/ If you find how to auto deploy please comment
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow