问题描述
我将公共密钥添加到github并尝试使用
进行克隆git clone git@github.com:xxx/yyy.git
和
git clone https://github.com/xxx/yyy.git
在我的私有计算机上git bash中。一切正常,但在连接到公司网络的计算机上,我只能通过git bash中的https进行克隆。对于ssh我遇到以下错误
ssh:无法解析主机名github.com:名称或服务未知 致命:无法从远程存储库读取。
我检查了〜/ .ssh文件夹,我认为一切正确。我也尝试过
git clone git@192.30.255.112:xxx/yyy.git
没有成功。也曾在其他论坛/问题中搜索失败。
有人知道这个问题的解决方案吗?
谢谢!
解决方法
生成一个ssh密钥并将其添加到Github。 https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
但是,如果您的公司正在使用代理,则需要使用以下命令告诉git:git config --global http.proxy http://proxyUsername:'proxypassword'@proxy.server.com:port