其他问题 ssh key 已经配置好,clone 远端库失败:

uncle7 · 2016年12月06日 · 最后由 hzdsay 回复于 2018年10月11日 · 603 次阅读

两台工作机:一个mac,一个ubuntu的虚拟机

1. 通过ssh clone项目,两台均 失败

git clone git@git.coding.net:myID/myProject.git *Cloning into 'myProject'... ssh: connect to host coding.net port 22: Connection refused fatal: Could not read from remote repository. Please make sure you have the correct access rights

and the repository exists.*

如果在config中写上: Port 443,也不行 git clone git@git.coding.net:myID/myProject.git *Cloning into 'myProject'... ssh_exchange_identification: Connection closed by remote host fatal: Could not read from remote repository. Please make sure you have the correct access rights

and the repository exists.*

ssh -T git@git.coding.net ssh: connect to host coding.net port 22: Connection refused ssh -Tv git@git.coding.net OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /home/alex/.ssh/config debug1: /home/alex/.ssh/config line 2: Applying options for git.coding.net debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to coding.net [221.193.246.84] port 22. debug1: connect to address 221.193.246.84 port 22: Connection refused ssh: connect to host coding.net port 22: Connection refused

2. 通过https clone

mac 没问题 ubuntu的虚拟机 一直提示要用户名和密码,即便key已经配置 git clone https://git.coding.net/myID/myProject.git Cloning into 'myProject'... Username for 'https://git.coding.net:' Password for 'https://git.coding.net:'

  1. 能否支持git@git.coding.net ? 2.ubuntu上即便配置了key,也要用户名和密码,能否用key登录?

求解,谢谢

共收到 5 条回复
ssh -T git@git.coding.net
ssh: connect to host coding.net port 22: Connection refused

为什么会连接 coding.net,你的 ssh_config 配置有问题吧,贴出来看看。

https 协议是需要输入用户名密码的,除非在 URL 上加上用户名密码,比如

https://username:password@git.coding.net/myID/myProject.git

但不建议这样写,这样密码会明文记录在 remote url 上,也可以只加

https://username@git.coding.net/myID/myProject.git

减少输入用户名那一步
又或者用其它有记住密码功能的 Git 客户端

Host coding.net *.coding.net
HostName coding.net
User .....
IdentityFile ~/.ssh/....

确实,改成:
Host git.coding.net
HostName git.coding.net
User ...
# PreferredAuthentications publickey
IdentityFile ~/.ssh/...
就好了。

多问下:
我的mac下为什么https clone不需要用户名密码,直接用key即可以?
git clone https://git.coding.net/YYY/XXX.git
Cloning into ‘XXX’...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

Host git.coding.net

HostName git.coding.net

User ...

PreferredAuthentications publickey

IdentityFile ~/.ssh/...

这个配置是直接在/root/.ssh/ 下新建config文件吗?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
相关话题