I have a problem trying to authenticate against a remote git repository hosted by scm manager on Linux with certain users.
The problem arises when I try to do an action which requires authentication, like git remote show origin
or git push
, while logged in on a Linux host as a local user account.
The same operation works fine on the same host when logged in with an LDAP account (both the linux host where I run the git commands and scm manager use the same credentials). In both cases I can clone the remote repository just fine.
I have unset GIT_ASKPASS and SSH_ASKPASS in both cases, to avoid graphical password prompts.
For example, I set up the local repository like this (I have previously-existing files):
git init
git remote add origin "http://[email protected]/scm/git/le_repo"
git remote show origin
My .git/config
file (I added the credentials section after doing git remote add origin
):
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://xxxx.com/scm/git/le_repo
fetch = +refs/heads/*:refs/remotes/origin/*
[credential "http://xxxx.com"]
helper = cache
username = my_ldap_user
When I try git remote show origin
with the local user account, git does (no password prompt):
[local_user@lehost ~]$ git remote show origin
error: The requested URL returned error: 401 Unauthorized while accessing http://xxxx.com/scm/git/le_repo/info/refs
fatal: HTTP request failed
The HTTP request is:
GET /scm/git/le_repo/info/refs HTTP/1.1
User-Agent: git/1.7.1
Host: xxxx.com
Accept: */*
Pragma: no-cache
With the LDAP user account (prompts for password):
[my_ldap_user@lehost ~]$ git remote show origin
Password:
* remote origin
Fetch URL: http://[email protected]/scm/git/le_repo
Push URL: http://[email protected]/scm/git/le_repo
HEAD branch: master
Remote branch:
master new (next fetch will store in remotes/origin)
The HTTP request:
GET /scm/git/le_repo/info/refs?service=git-upload-pack HTTP/1.1
Authorization: Basic Zzzzzzzzzzzzzzzz=
User-Agent: git/1.7.1
Host: xxxx.com
Accept: */*
Pragma: no-cache
I think I should be able to authenticate against scm manager as my_ldap_user
in both cases, what is wrong here?