[英]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.我正在为我的新 Gitlab 服务器(版本
12.10.3
)和我的本地 git 项目而苦苦挣扎:我正在尝试导入它,但是我坚持使用远程 ZE6B391A8D2C4D45902A23A8B 设置。
With the following URL, git asks me a password:使用以下 URL,git 向我询问密码:
git remote set-url origin git@192.168.1.20:mygroup/data/myproject.git
git push --all
git@192.168.1.20'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:为避免这种情况,我在另一个主题中添加了红色,我需要在 URL 的开头添加
ssh://
以使其正常工作,然后:
git remote set-url origin ssh://git@192.168.1.20: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.当然,当我从我的工作站执行
ping
操作时,可以访问 IP 地址。 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 密钥,将其添加到我的 Gitlab 帐户中,并将 gitlab 的公钥添加到
known_hosts
文件夹中:
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.看起来我的 SSH 密钥可能存在问题。 I've tried to debug it with
ssh -Tvvv git@192.168.1.20
, and I've got the following output:我尝试使用
ssh -Tvvv git@192.168.1.20
进行调试,并且得到以下 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
git@192.168.1.20'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.我在
/c/Users/MyName/.ssh/id_rsa
中的密钥已用于进行身份验证,但由于某些隐藏的原因,它不起作用。
I've checked again on Gitlab SSH keys
section, and the key is exactly the same as expected.我再次检查了 Gitlab
SSH keys
部分,密钥与预期完全相同。
git remote set-url origin git@192.168.1.20:mygroup/data/myproject.git
git push --all
git@192.168.1.20's password:
I've also setup my SSH key
我还设置了我的 SSH 密钥
Well, looks like you didn't.嗯,看起来你没有。 To verify it start debugging with
ssh -Tv git@192.168.1.20
.要验证它,请使用
ssh -Tv git@192.168.1.20
开始调试。
git remote set-url origin ssh://git@192.168.1.20:mygroup/data/myproject.git
The correct SSH URL syntax is ssh://[user@]host.xz[:port]/path/to/repo.git/
.正确的 SSH URL 语法是
ssh://[user@]host.xz[:port]/path/to/repo.git/
。 See the different syntax in the docs .请参阅文档中的不同语法。
In your case the URL should be ssh://git@192.168.1.20/mygroup/data/myproject.git
.在您的情况下,URL 应该是
ssh://git@192.168.1.20/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/
.冒号仅用于在类似 scp 的语法
[user@]host.xz:path/to/repo.git/
host
与路径分开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.