difference between https git clone and ssh git clone

19,342

Git uses several protocols for client-server communication:

  • http
  • https
  • ssh
  • git

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 a git-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. Using ssh 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.

Share:
19,342

Related videos on Youtube

Shailesh Sutar
Author by

Shailesh Sutar

All posts are imaginary and fictional. A resemblance to any current or past affair is pure coincidence. IT Engineer by profession. Curious about human behavior.

Updated on September 18, 2022

Comments

  • Shailesh Sutar
    Shailesh Sutar over 1 year

    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.
    
  • Shailesh Sutar
    Shailesh Sutar over 7 years
    Thanks for the information however I am still confused about the which protocol is been used when I use git clone [email protected]:star/test-repo.git My user is not able to git clone the repo.
  • 13dimitar
    13dimitar over 7 years
    that's ssh - git clone user@address:/repo/location/repo.git