Gitlab Runner registration return (401 Unauthorized) - https

We have installed gitlab runner on redhat server but we can't register it with our gitlab instance as it is protected (we need to login before it shows HTTPS).
When we clone the project repository:
git clone https://domain\.com/project.git
It asks for username and password and if we store credentials in a file or cache like
git config --global credential.helper 'store --file ~/.my-credentials'
it will ask the first time only for authentication when cloning => my-credentials will contains the raw username/password but it solves the problem of being asked for authentification each time.
How can we do the same things with the runner in order to register it to our gitlab :
when we run
gitlab-runner register --url http://domain\.com/gitlab/ -r 1TqfdYFsJsdsdLNc-7J
we got immediately the below error without asking us for username/password :
ERROR: Registering runner... failed runner=1TqfdYFs status=401 Unauthorized
PANIC: Failed to register the runner. You may be having network problems.
we know that the runnercan't access our gitlab because of the authentification needed but we don't know how to solve it we tried many things like saving credentials in git cache but it seems that they are not connected or use the same things.
Any ideas please ?

I see that you are trying to register your runner with http method. Try registering with https instead. This resolved the issue for me.
gitlab-runner register --url https://domain\.com/gitlab/ -r 1TqfdYFsJsdsdLNc-7J

Related

Downloading Laravel Admin Requires Me Git Credentials However It Is a Public Repo

I'm using Laravel 8 and I wanted to download and install Laravel-Admin but I faced this error on IDE Terminal:
Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+ITnanoclub+2022-10-23+1036
to retrieve a token. It will be stored in "C:/Users/User 1/AppData/Roaming/Composer/auth.json" for future use by Composer.
Token (hidden):
I tried connecting with VPN but again showed me this error...
So what's going wrong here? How can I solve this issue?
I would really appreciate if you share any idea or suggestion about this with me please...
Here is the screenshot:
Here is ping result:
It is a public repository, but if your command tries a clone through SSH first, it might fall back to HTTPS and ask for credentials as part of its fallback mechanism.
That would be different if it tries immediately to clone with HTTPS: since it is a public repository, it would not require HTTPS credentials.
For that, try and set:
git config --global url."https://github.com/".insteadOf ssh://git#github.com/
git config --global url."https://github.com/".insteadOf git#github.com:
Then try again your composer require encore/laravel-admin

Jenkins git authentication failed with correct credentials on Windows

I'm currently using Jenkins on Windows 10, and using git as version control system.
Although I provided correct repository URL and credential, I cannot use jenkins with error below.
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git#URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Credential and URL doesn't seems wrong, since this build success previously with same credential. The only change after successful build was one line in build script.
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
After I success with this script, git setting keeps failed. Is there any problem with that line? And how can I fix it?
EDIT
Problem solved! For anyone who has same problem, it was problem with the system user! Since ssh key stores in each user space, jenkins cannot detect where the ssh key located. Therefore, go to 'service' in windows, and change user of jenkins service to the user who has correct ssh key. It solved my problem!
Seems there is some problem in Jenkins.
It cannot locate OpenSSH folder in System32, and so that I cannot get log with it.
That would explain why the main Jenkins controller (aka "master" in old terminology) cannot contact the Git repository (assuming an SSH URL here, with technical remote user account "git")
Try and remove that git configuration to see if the error persists: Git should fall back to its own ssh.exe, packaged with Git For Windows.
As noted by the OP, this only works if said Jenkins is run as a user account, not as the system account.
Only then will it be able to access the %USERPROFILE%\.ssh folder.

Visual Studio - Git clone fails over SSH, but works over HTTPS

I am using a fresh install of Visual Studio 2017 (15.8.1), and Git tools.
When I try to clone an existing GitHub repository, either by using the commandline tools, or by using git tools, I receive the following error message:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I believe this error is caused by SSH and I cannot seem to make git use HTTPS. Thanks in advance.
If you are using 2-factor authentication at GitHub
You must either do one of the following:
Use the SSH link, add an SSH key to your GitHub account and load it using the SSH agent in Windows, this may be done using Putty.
Generate a personal access token, and use the HTTPS link. Use your GitHub username as the username, but use the generated access token as your password.
If you want to clone any repository using https
Simply clone it using the HTTPS-link instead of the SSH link. You can find both links here, by clicking on Use SSH, you can switch to the SSH link:
In my case, I had to delete ~/.ssh/known_hosts file, so that a new one will be made next time you access git over ssh.

Jenkins: Can't fetch project's source code from GitLab

I run my Jenkins server on the local machine, and I met problem with fetching project from GitLab repository. I don't know exactly what I have to done.
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --progress http://repository.vrpconsulting.com/roman.skaskevich/koshcheck-copy.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Logon failed, use ctrl+c to cancel basic credential prompt.
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'http://repository.vrpconsulting.com/roman.skaskevich/koshcheck-copy.git/'
GITLAB SETTINGS: here
EDIT #1
When I run git fetch --tags --progress http://repository.vrpconsulting.com/roman.skaskevich/koshcheck-copy.git +refs/heads/*:refs/remotes/origin/* on local machine, it performs successfully and dialog for entering login/password is showed.
But what I have to do that jenkins job performed this command successfully?
EDIT #2
For now, Credentials Binding Plugin helps me implements to checking credentials in Jenkinsfile.
EDIT #3
I run Jenkins server on another machine and have the same problem. I don't want to use login/password, so adding SSH key solved this problem.
Thanks in advance!
Seems like your repo is private. Private git repos requires authentication. Reconfigure your git client plugin check if you are able to connect to remote repo via password based authentication , if not , try SSHing to the repo.
Looks like this ins private repo if you want to clone that repo to jenkins workspace you need to provide your gitlab credentials in jenins.
for that, you need to install jenkins plugin called "Gitlab Authentication plugin". once you completed the installation please do a restart.
Add Gitlab credentials in "Jenkins Credentials Provider: Jenkins".
later you can add your gitlab credentials in Source Code Management
Source Code Management
in credentials select the saved gitlab credentials.
Steps:
Install plugins:
Gitlab
Gitlab authentication
Configure global credentials in jenkins:
go to credentials >> system >> global creds >> username & password
ID: git
username: your gitlab username
password: your gitlab password
Pipeline:
stage('SCM') {
steps {
git credentialsId: 'git', url: 'your gitlab url'
}
}
I got this error too. In my case, the git repo is a private one.
I added the git link and then supplied the git credentials to the particular Jenkins job. The issue is gone and able to build project from Jenkins.

gcloud init fails for invalid username/password

I am trying to gain access to the embedded git repository for an existing Google Developers Console (GDC) project. The GDC shows the git repository under -SOURCE CODE-Releases. I followed the official gcloud installation instructions to the point:
gcloud auth login /* pulls up browser and does authentication just fine */
gcloud config set project <project>
gcloud init <project>
The latter always results in the following (replacing actual project name with 'fishbone'):
$gcloud init fishbone
Initialized gcloud directory in [/Users/dummy/Workspace/fishbone/.gcloud].
Cloning [https://source.developers.google.com/p/fishbone/r/default] into [default].
Initialized empty Git repository in /Users/dummy/Workspace/fishbone/default/.git/
fatal: remote error: Invalid username/password.
You may need to use your OAuth token password; Note that generated google.com passwords are not compatible with private repositories
ERROR: Unable to initialize project [fishbone], cleaning up [/Users/dummy/Workspace/fishbone].
ERROR: (gcloud.init) Could not fetch repository.
Only on the very first installation of the SDK (re-tried more than once now), I remember gcloud init asking for a username. Never again after this. Mac OS X 10.9.3 and:
$git --version
$git version 1.8.5.2 (Apple Git-48)
I am aware of this related gcloud init issue, but it's not this. Help greatly appreciated.
Go to https://console.developers.google.com/project/your-project-id > Source Code > Browse > Find this line : "Alternatively, instead of using the Google Cloud SDK to manage your authentication, you can manually generate your Git credentials by following this link." > Click "following this link" and you can see your git password. As you can see in your error, google password are not compatible with private repositories. Now you can :
Use your gmail and git password above to clone reposite.
Or create .netrc file at your home folder and add : "machine source.developers.google.com login your-email#gmail.com password 1/abxxxxxxxxxxxxxxxxxxxxxxx" to this file. It will not request your password again.
Just goto your Google Developer Console and click /
find the content like below
"Alternatively, instead of using the Google Cloud SDK to manage your authentication, you can manually generate your Git credentials by following this link."
and click "following this link" then follow the instructions on that page.
Thats all.
They moved the options to manually created Git credentials. The options are now under GCP -> (tools) Development -> Source Code
and under the options when cloning new or existing repos they give you the option to use gcloud or create your own credentials.
also below in screenshots

Resources