Reputation: 1758
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?
Upvotes: 6
Views: 3339
Reputation: 1758
The following clues helped in diagnosing the problem.
First, lets try ssh -vT without specifying a user. Note that the session assumes that the user is the account that is logged on, which has special character ('SE121947+PVHF0ONE_SS')!
$ ssh -vT git-eim.fg.com
OpenSSH_7.1p2, OpenSSL 1.0.2g 1 Mar 2016
....
debug1: Authenticating to git-eim.fg.com:22 as'SE121947+PVHF0ONE_SS'
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/PVHF0ONE_SS/.ssh/id_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Now lets try it with specifying [email protected]
$ ssh -vT [email protected]
OpenSSH_7.1p2, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to git-eim.fg.com [10.238.35.34] port 22.
debug1: Connection established.
debug1: identity file /c/Users/PVHF0ONE_SS/.ssh/id_rsa type 1
...
debug1: kex: server->client [email protected] <implicit> none
Authenticated to git-eim.fg.com ([10.238.35.34]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi PU0R0SRVDEVOPS! You've successfully authenticated, but GitHub does not provide shell access.
Strange thing is git@
can be replaced by foo@
and the authentication works! It's almost like it is merely a placeholder. So the fix was making sure the developerConnection
in the pom.xml had a git@
in order for git to be able to authenticated.
Upvotes: 0
Reputation: 1324228
Any idea why the following command fails
git clone ssh://git-eim.fg.com/u0r0-SS/workspace-proxy.git
but the following succeedsssh://[email protected]/u0r0-SS/workspace-proxy.git
?
What is special aboutgit@
?
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
.
Upvotes: 2
Reputation: 142084
git looks for the ssh in a certain location under you .ssh folder.
Set the keys in the config file and you should be able to clone it.
Open a terminal window.
Edit the ~/.ssh/config
file.
If you don't have a config file, create one.
Add an alias for each identity combination for example:
Host workid
HostName github.com
IdentityFile ~/.ssh/workid
Upvotes: 0