https git clone和ssh git clone之间的区别

您好我现在使用git一段时间,但我是企业git的新手。 这里是我做我的test-repo我做了一个SSH密钥对,并添加公钥作为我的testing回购部署的关键。 现在我可以从sshhttps克隆我的test-repo ,但是当我添加某人作为合作者时,他们能够从https克隆回购,而不是从ssh

 ssh-keygen -b 4096 -t rsa -f example_rsa -P "" -C "" $ ls example_rsa example_rsa.pub $ git clone [email protected]:star/test-repo.git Cloning into 'test-repo'... Warning: Permanently added the ECDSA host key for IP address '10.0.1.100' to the list of known hosts. warning: You appear to have cloned an empty repository. 

即使在通过ssh授予访问权后,用户也不能访问相同的git repo,但是用户可以使用https来克隆repo。

 git clone [email protected]:star/test-repo.git Cloning into 'test-repo'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. git clone https://git.example-private.com/star/test-repo.git Cloning into 'test-repo'... warning: You appear to have cloned an empty repository. 

Git使用几种协议进行客户机 – 服务器通信:

  • HTTP
  • HTTPS
  • SSH
  • 混帐

当你决定为你的git服务器使用ssh的时候,你需要为将要与你的存储库一起工作的协作者提供相关的ssh访问权限。 有很多解决scheme来减轻pipe理 – gitlab(它也有GUI),gitolite等等。 甚至Git带有一个git-shell – 如果你把它设置为一个新创build的用户,他将只能使用git,而不是SSH到服务器。 使用ssh更安全,对于企业环境来说是更好的解决scheme(我认为)。

当您使用https传输协议时,您将获得https的优势(或局限性)。 当你有一个你的git服务器(例如cgit)的web界面时,它是最常用的,它允许用户克隆版本库(但不是推)。

请看看这个 – 关于在Git中使用的协议的详细解释。