简体   繁体   中英

git push is failing - Permission denied (publickey)

I have a gerrit server with multiple repos.

in the manifest i am using the https://url and it works fine for fetching.

i set a sshl pushurl="ssh://ssh-dns-name:29418" (note no username as part of this).

When i do the sync all the projects have remotes like -

origin  https://url/my_project  (fetch)
origin ssh://ssh-dns-name:2941/my_project (push)

now, when i do push, the git is complaining that Permission denied (publickey)!!!

i see that the user.name and user.email are setup properly. user.name "Abhayadev S" (whic is setup in gerrit as user Full name) and user.email "abhayadevs...@in.com" which is setup in gerrit as user email

also my client machine login name is "abhayadevs" which is the gerrit username.

if i use the username in the pushurl ( ssh://abhayadevs@ssh-dns-name:29418 ), everything is working fine !

so i am confused, why git is not taking the username !!!! i checked the git config --local --list , nothing is set locally..! only global git config has the user.name and user.email !!!

The user.name and user.email configurations have no effect on authentication in any way. They affect only the personal name and email address you put in a commit or tag.

If it works for you to put the username in the push URL, then do that: that's the simplest, easiest way to make this work. Every user using a site such as GitHub or GitLab must put the username ( git ) in the URL, so doing so shouldn't be a problem. If you don't specify a username, the default is determined by OpenSSH and usually defaults to that of your local user, although it is case sensitive. You can also override it explicitly in ~/.ssh/config if you need to, but it's probably just easier to specify it in the URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM