Hi I am using git for a while now however I am new to enterprise git. here
Is what I did with my test-repo
I created a ssh key pair and added public key to my test repo as deploy key. Now I can clone my test-repo
from ssh
and https
however when I add someone as collabrator they're able to clone repo from https
but not from 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.
Same git repo can't be accessed by user even after granting access via ssh however user can git clone the repo using https
.
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 uses several protocols for client-server communication:
When you decide to use
ssh
for you git server, you need to provide relevant ssh access for the collaborators who are going to work with your repositories. There are plenty of solutions to ease the manage - gitlab (it has GUI too), gitolite and many others. Git even comes with agit-shell
- if you set it to a newly created user, he will be only able to work with git, and not ssh into the server. Usingssh
is more secure and is the better solution (my opinion) for enterprise environments.When you use https for transport protocol you get the advantages (or limitations) of https. It is most commonly used when you have a web interface for your git server (e.g. cgit) and it allows users to clone repositories (but not to push).
Please have a look at this - a detailed explanation about the protocols used in Git.