git clone from internal gitlab repository doesn't work unless I'm running as root - linux

I'm trying to clone an internal gitlab repository, but it keeps giving me this error message
fatal: unable to access 'https://gitlab**************.git/': gnutls_handshake() failed: Error in the pull function.
But somehow, if I'm running as root, the cloning process would run perfectly.
The problem is, I needed this to work because I'm trying to use this repository on Jenkins.
Can someone help me or explain why it only worked if I'm running as root?

root uses the same version of git and curl.
But it does not use the same:
global git config: compare the output of git config --global -l in both instances (root and regular user account).
environment configuration (type env in both cases, and compare the environment variables)
In particular, look for sslcainfo (git config --global -l|grep -i ssl) which could reference the certificate needed to contact through TLS your on-premise HTTPS GitLab URL.

Related

Can't interact with github

My laptop runs arch linux. I wanted to use github to backup my project. In the beginning everything worked fine, I was able to push the first two commits.
Then I wanted to push the third commit but it took forever. From then on every communication (push, pull, clone etc. on multiple repositories) with the remote repository took forever and ended with the error: fatal: could not read from remote repository. There was one exception where i was able to push. Afterwards it was the same again.
The ssh authentication is working. ssh git#github.com delivers the expected response. (ssh -T git#github.com takes forever and is not successful - is this relevant?)
There are a few similar threads but I haven't found a working answer.
What i have already tried:
Checked remote repository (git remote -v): -- is correct
Started ssh-agent and added key (eval `ssh-agent`, ssh-add)
Forcing ssh to use IPv4 (in ~/.ssh/config: AddressFamily inet)
Removed git enviroment variable (unset GIT_SSH)
Tried multiple keys (rsa, ed25519) with/without password
Used the url wiht ssh:// scheme (ssh://git#yourhost:port/path/repo.git)
Updated git
Complete update of the os
Credential helper disabled (git config --global --unset credential.helper)
Checked credentials (git config --global user.name , git config --global user.email)
I even tried to trace the git pull:
GIT_TRACE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_SETUP=2 git push -u origin main --verbose
With the result:
14:10:30.980851 trace.c:312 setup: git_common_dir: .git
14:10:30.980857 trace.c:313 setup: worktree: /home/alex/Entwicklung/NetCore/ActivityTrackerPC
14:10:30.980863 trace.c:314 setup: cwd: /home/alex/Entwicklung/NetCore/ActivityTrackerPC
14:10:30.980868 trace.c:315 setup: prefix: (null)
14:10:30.980872 git.c:460 trace: built-in: git push -u origin main --verbose
Push nach github.com:2kHammer/ActivityTracker.git
14:10:30.984208 run-command.c:655 trace: run_command: unset GIT_PREFIX; ssh git#github.com 'git-receive-pack '\''2kHammer/ActivityTracker.git'\'''
Then it hangs until the error occures.
For now i copied the project to my raspberry und pushed from there. There it worked without problems.
I am really desperate, git is an essential tool.
Try to re add your ssh key to your ssh agent
ssh-add ~/.ssh/id
where id is the ssh key is the key associated with your github repository

"git push -u origin --all" fails only from AWS virtual Linux instance - possibly ssh related

Pardon my ignorance here.
I have a local Windows machine using which if I run the following commands on a Windows cmd prompt, they all work:
git config --global user.email "myuser#abc.com"
git config --global user.name "myuser"
cd Try (some dir holding a single readme file)
git init
git add .
git commit -am "initial"
git remote add origin git#mygiturl.git (URL where I want to check into)
git remote -v
git push -u origin --all
However, if I try running the exact same set of commands from a Linux server (EC2 instance spawned in AWS), it throws:
ubuntu#ip:~/try$ git push -u origin --all
GitLab: The project you were looking for could not be found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm guessing it's possible got to do with ssh and/or authentication, but it doesn't error out with "permission denied".
If I run these same from Ubuntu Linux subsystem on Windows, the "git push -u origin --all" fails with permission denied instead.
git#gitlab....: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Any inputs are appreciated.
GitLab: The project you were looking for could not be found. fatal:
Could not read from remote repository. Please make sure you have the
correct access rights and the repository exists.
Most likely cause to this is that your Amazon EC2 instance does not have any connectivity to the internet. This maybe be because it is in the private subnet or you have some security group rules to block the outgoing connection. If your instance is in private subnet then you may need to associate a NAT gateway and add a route table entry to allow the ec2 instance reach to the internet.

GitHub SSH access not working

I have created a new user on github under our organization which will be used for auto deployment. I followed the article on https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux.
Somehow, when I tried to clone the repository to the server, it worked once. The code was running properly, and I exit the server. Today, we released an update to the code, and I wanted to deploy the code manually to the server, so I ssh'd into the server and tried to pull the repository with git pull. It gave me Permission denied error. After some debugging I realized that the ssh-agent wasn't running. So I executed the following commands:
eval "$(ssh-agent -s)"
ssh-add .ssh/id_rsa_staging
Now, when I try ssh -T git#github.com, I see the welcome message which is:
Hi *****! You've successfully authenticated, but GitHub does not provide shell access.
But when I try to pull from the repository, I am continuously getting this error message:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I checked the repository and the user has read access to it. I double checked if the keys match on github and server, yes they do. I tried generating new keys. I tried using ssh/config file. Nothing helped...
I appreciate any help & suggestions!
Update:
So I figured out that git clone command is working properly, but even when I try git pull right after git clone, it is giving the error.
If you are using sudo to git pull/push to the remote you need to ensure you used sudo to generate your SSH keys. Otherwise you will not be using the same keys that you originally generated.
github doc for reference
I had the exact same issue.
For me what worked was
Go to repo on github which you have cloned and wanna pull with
Under the code-download option copy SSH link
Enter following command in your terminal -->
git remote set-url origin paste_SSH_link

Cannot create a working Git server

I have installed Git on my machine and finished the setup of every thing. Git is working fine locally, but when i try to access it globally always return the following
fatal: '/Gittest/project.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
I can access the server where the repository is identified through ssh connection. and access the files in the Git directory, though i can't set the directory as my remote origin
what should i do?
I have used the following command to set remote repository
git remote add origin svn#192.168.1.60:MDosoky/Gittest/project.git
and I have checked the connectivity from the client by using the following command
scp svn#192.168.1.60:MDosoky/Gittest/clientm.txt temp
where clientm is in the same location as project.git
It seems that I have entered a wrong public key instead of the user I was working on, the problem is solved by changing the public key in the server file

Unable to clone repository to jenkins on linux

I am able to clone a repository that i've created for one of my jobs on jenkins. Whereas, cloning a repository which is a fork of another repository gives the following error when trying to build it - Any suggestions on what could be the problem?
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/client1/workspace
Checkout:workspace / /var/lib/jenkins/jobs/client1/workspace - hudson.remoting.LocalChannel#1d5cac4
Using strategy: Default
Cloning the remote Git repository
Cloning repository https://..... (couldn't disclose the address link here)
git --version
git version 1.7.9.5
ERROR: Error cloning remote repo 'origin' : Could not clone https://.....
hudson.plugins.git.GitException: Could not clone https://......
at hudson.plugins.git.GitAPI.clone(GitAPI.java:273)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1044)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:865)
at hudson.FilePath.act(FilePath.java:838)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1331)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:682)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:587)
at hudson.model.Run.execute(Run.java:1557)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
My first guess would be that the user jenkins is running as does not have permission to access the git repo.
I would try logging into the server and running
sudo su <jenkins_user_name>
git clone https://.....
You may just need to add the server to your known hosts if the SSH Keys are already setup.

Resources