toshiro92
toshiro92

Reputation: 1344

Local Git cannot resolve hostname with "ssh://" in the config, and asking for password without

I'm struggled with my new Gitlab server (version 12.10.3) and my local git project: I am trying to import it, however I'm stuck with the remote URL settings.

With the following URL, git asks me a password:

git remote set-url origin [email protected]:mygroup/data/myproject.git
git push --all
[email protected]'s password:

To avoid that, I've red in a different topic that I need to add ssh:// at the beginning of the URL to make this working, and then:

git remote set-url origin ssh://[email protected]:mygroup/data/myproject.git
git push --all
ssh: Could not resolve hostname 192.168.1.20:mygroup: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

Of course, the IP address is reachable when I do a ping from my workstation. I've also setup my SSH key, added it to my Gitlab account, and added the gitlab's public key in the known_hosts folder:

ssh-keyscan 192.168.1.20 >> /c/Users/MyName/.ssh/known_hosts

Did I missed something?

EDIT

Looks like there is potentially an issue with my SSH key. I've tried to debug it with ssh -Tvvv [email protected], and I've got the following output:

[...]
debug1: Will attempt key: /c/Users/MyName.ssh/id_rsa RSA SHA256:+W7oskD00BfECMDiA0jTGA4pQbxeNT3v2OFrULoJ7ts
debug1: Will attempt key: /c/Users/MyName/.ssh/id_dsa
debug1: Will attempt key: /c/Users/MyName/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/MyName/.ssh/id_ed25519
debug1: Will attempt key: /c/Users/MyName/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/MyName/.ssh/id_rsa RSA SHA256:+W7oskD00BfECMDiA0jTGA4pQbxeNT3v2OFrULoJ7ts
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /c/Users/MyName/.ssh/id_dsa
debug3: no such identity: /c/Users/MyName/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /c/Users/MyName/.ssh/id_ecdsa
debug3: no such identity: /c/Users/MyName/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /c/Users/MyName/.ssh/id_ed25519
debug3: no such identity: /c/Users/MyName/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /c/Users/MyName/.ssh/id_xmss
debug3: no such identity: /c/Users/MyName/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password:

It seems it used the certificate authentication process. My key in /c/Users/MyName/.ssh/id_rsa has been used to authenticate, but for some hidden reason, it didn't worked.

I've checked again on Gitlab SSH keys section, and the key is exactly the same as expected.

Upvotes: 2

Views: 695

Answers (1)

phd
phd

Reputation: 94425

git remote set-url origin [email protected]:mygroup/data/myproject.git
git push --all
[email protected]'s password:

I've also setup my SSH key

Well, looks like you didn't. To verify it start debugging with ssh -Tv [email protected].

git remote set-url origin ssh://[email protected]:mygroup/data/myproject.git

The correct SSH URL syntax is ssh://[user@]host.xz[:port]/path/to/repo.git/. See the different syntax in the docs.

In your case the URL should be ssh://[email protected]/mygroup/data/myproject.git. The path isn't separated with :, it's started with /. A colon is used to separate host from the path only in scp-like syntax [user@]host.xz:path/to/repo.git/.

Upvotes: 1

Related Questions