【问题标题】:git clone over https 401 error and not asking for username or passwordgit clone over https 401 错误并且不询问用户名或密码
【发布时间】:2011-08-13 08:41:20
【问题描述】:

我在 Codaset 上有一个私有 git 存储库。通常,当我尝试在我的 Windows 机器上通过 HTTPS 克隆它时,它会询问我的用户名和密码。当我尝试在 Ubuntu 服务器上克隆它时,它从不要求我输入用户名或密码,并且失败并出现 401 错误。我需要做些什么不同的事情?

这是我正在做的:

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

【问题讨论】:

    标签: git ubuntu https


    【解决方案1】:

    你可以这样做:

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

    让它提示输入密码。

    【讨论】:

    • 确实提示我输入密码,但它仍然失败并出现错误 502
    【解决方案2】:

    为了完全避免输入密码(在 Windows 或 Unix 上),您可以:

    • 检查 HOME 是否已定义(在 Windows 上,默认情况下未定义)
    • 设置一个_netrc文件,内容如下:
    机器 codaset.com 登录 your_codaset_login 密码 your_codaset_password

    注意:%HOME%\_netrc 在 Windows 上,$HOME/.netrc 在 Unix 上

    这样,当你克隆你的 repo 时,而不是输入:

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

    ,可以去掉初始用户名:

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

    而且您不必输入密码。


    如果您不想在.netrc 文件中以纯文本 的形式将您的凭据(尤其是您的密码)放入,您可以使用@987654330 加密该netrc 文件@:见“Is there a way to skip password typing when using https:// github

    【讨论】:

    【解决方案3】:

    我让它使用这种格式工作:

    https://username:password@codaset.com/username/project_name.gitdestination_folder

    但是根据这两个帖子,使用该方法可能存在安全问题:

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

    Username and password in https url

    【讨论】:

      猜你喜欢
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 2016-12-06
      • 2021-01-27
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      • 2013-10-03
      相关资源
      最近更新 更多