Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git push fails with public key when using SSH and specifying credentials

I have a weird issue here. Our Maven release plugin fails because it can't push a tag to Git. The following fails:

git push ssh://PU0S:[email protected]/u0r0-SS/workspace-proxy.git workspace-proxy-server-1.10.1
[ERROR] Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR] 
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.

If I remote into the machine and try pushing with an URL of the form I get the same error:

git push ssh://PU0S:[email protected]/u0r0-SS/workspace-proxy.git

If I just push using the defined remote, it succeeds:

git push origin master

The above makes me certain that the .ssh keys are available on the machine. Why does the first form fail?

like image 833
timmy Avatar asked Oct 30 '22 00:10

timmy


1 Answers

Any idea why the following command fails git clone ssh://git-eim.fg.com/u0r0-SS/workspace-proxy.git but the following succeeds ssh://[email protected]/u0r0-SS/workspace-proxy.git?
What is special about git@?

git@ means the user which will receive the push will be git. The authentication is then managed by the public key used for ssh.
This differs from PU0S:xL8q, which is a username/password, only required when using an https url.
For an ssh url, you never push "as you" (PU0S) but as the account managing the git repos on the server side.
That is why, for instance, you always push at [email protected].

If git push origin master succeeds, that means the url associated to the remote named 'origin' is correctly formed.
Typically ssh://[email protected]/u0r0-SS/workspace-proxy.git.

Check with git remote -v, or, since git 2.7, with git remote get-url origin.

like image 78
VonC Avatar answered Nov 15 '22 07:11

VonC