我在Codaset上有一个私人的git仓库。 通常,当我尝试通过Windows计算机上的HTTPS克隆它时,它会询问我的用户名和密码。 当我尝试在Ubuntu服务器上克隆它时,它永远不会要求我input用户名或密码,并且会因401错误而失败。 我需要做什么不同?
这是我在做什么:
git clone https://codaset.com/username/project_name.git destination_folder_name.git
我得到它使用这种格式的工作:
https://用户名:password@codaset.com/username/project_name.git destination_folder
然而,根据这两个职位,使用这种方法可能是一个安全问题:
用户名和密码是否可以通过URL参数通过HTTPS安全发送?
用户名和密码在https网址
为了避免必须输入密码(在Windows或Unix上),您可以:
_netrc
文件: 机器codaset.com 登录your_codaset_login 密码your_codaset_password
注意:Windows上的%HOME%\_netrc
,Unix上的$HOME/.netrc
这样,当你克隆你的回购,而不是打字:
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
文件中以明文形式输入你的凭证(特别是你的密码),你可以使用gpg
来加密这个netrc
文件 :参见“ 有没有办法在使用https://时跳过密码输入github “
你可以做:
git clone https://username@codaset.com/username/project_name.git destination_folder_name.git
使其提示输入密码。