14

I have a private git repository on Codaset. Normally when I try to clone it over HTTPS on my Windows machine, it asks me for my username and password. When I try to clone it on an Ubuntu server, it never asks me for a username or password and it fails with a 401 error. What do I need to do differently?

Here is what I am doing:

git clone https://codaset.com/username/project_name.git destination_folder_name.git
still_dreaming_1
  • 8,661
  • 6
  • 39
  • 56

4 Answers4

18

I got it to work using this format:

https://username:password@codaset.com/username/project_name.git destination_folder

However according to these 2 posts, using that method could be a security problem:

Can a username and password be sent safely over HTTPS via URL parameters?

Username and password in https url

Community
  • 1
  • 1
still_dreaming_1
  • 8,661
  • 6
  • 39
  • 56
12

To avoid having to enter a password at all (on Windows or Unix), you can:

  • check that HOME is defined (on Windows, it isn't by default)
  • setup a _netrc file with the following content:
    machine codaset.com
    login your_codaset_login
    password your_codaset_password

Note: %HOME%\_netrc on Windows, $HOME/.netrc on Unix

That way, when you are cloning your repo, instead of typing:

 git clone https://username@codaset.com/username/project_name.git destination_folder_name.git

, you can remove the initial username:

git clone https://codaset.com/username/project_name.git destination_folder_name.git

and you won't have to enter a password.


If you don't want to put your credentials (in particular your password) in plain text in an .netrc file, you can encrypt that netrc file with gpg: see "Is there a way to skip password typing when using https:// github"

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @zhaozhi great. You even can encrypt that `.netrc` file if you don't want your password put in plain text in a file: http://stackoverflow.com/a/18362082/6309 – VonC Jan 14 '14 at 06:56
11

You can do:

git clone https://username@codaset.com/username/project_name.git destination_folder_name.git

to make it prompt for password.

manojlds
  • 290,304
  • 63
  • 469
  • 417
0

Had the same question but my issue was because git was outdated with version 1.7.1. Updating git solved it. Here's how: https://travis.media/how-to-upgrade-git-on-rhel7-and-centos7/

Jacobski
  • 741
  • 6
  • 10