[英]How to use PAT on Azure DevOPS Server to clone a git repo
Hi we are trying to clone a git repo from our local Azure DevOps server 2020.0.1.您好,我们正在尝试从本地 Azure DevOps 服务器 2020.0.1 克隆一个 git 存储库。 We are using the command bellow, but it is not working.我们正在使用下面的命令,但它不起作用。 Should this be possible?这应该是可能的吗?
The documentation I try to follow is this .我尝试遵循的文档是this 。 But it is a bit unclear.但是有点不清楚。
git clone https://{an username:yourPAT}@yourURL/yourOrgName/yourProjectName/_git/yourRepoName
We then get an error: "fatal: Authentication failed for "然后我们得到一个错误:“fatal: Authentication failed for ”
We also tried variations like 'yourname:yourPAT', 'yourPAT', ':yourPAT', 'yourPAT:' We want to use PAT's together with SmartGit我们还尝试了像 'yourname:yourPAT', 'yourPAT', ':yourPAT', 'yourPAT:' 这样的变体 我们想将 PAT 与 SmartGit 一起使用
We then tried to use the other method mentioned (but when reading this is only needed when using basic authentication, we never enabled this on our ADOS-server, and is also not an authentication method on our IIS-website:然后我们尝试使用提到的其他方法(但是当阅读时只有在使用基本身份验证时才需要,我们从未在我们的 ADOS 服务器上启用它,并且也不是我们 IIS 网站上的身份验证方法:
$MyPat = 'yourPAT'
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$MyPat"))
git -c http.extraHeader="Authorization: Basic $B64Pat" clone https://{yourURL/yourOrgName/yourProjectName/_git/yourRepoName
This one is working这个正在工作
The PAT we created is with full scope and access to all organizations.我们创建的 PAT 具有完整的 scope 和所有组织的访问权限。
The PAT is working to add an Agent. PAT 正在努力添加代理。
We can also use it to access the RESTAPI (with curl you should -u and random or empty username, so bla;yourPAT).我们还可以使用它来访问 RESTAPI(使用 curl 你应该 -u 和随机或空的用户名,所以 bla;yourPAT)。
Any advice is appreciated.任何建议表示赞赏。
Based on your description, when you use the basic auth to run the git command, it could work.根据您的描述,当您使用基本身份验证运行 git 命令时,它可以工作。
It seems that the basic auth is enabled.似乎启用了基本身份验证。
If you enable IIS Basic Authentication for Azure Devops server, PATs aren't valid.如果为 Azure Devops 服务器启用 IIS 基本身份验证,则 PAT 无效。 See Enabling IIS Basic Authentication invalidates using Personal Access Tokens .请参阅启用 IIS 基本身份验证使使用个人访问令牌无效。
If you use Git with IIS Basic Authentication, Git breaks because it requires PATs for user authentication.如果您将 Git 与 IIS 基本身份验证结合使用,则 Git 会中断,因为它需要 PAT 来进行用户身份验证。 Although we don't recommend you use IIS Basic Authentication, by adding an extra header to Git requests, you can use Git with IIS Basic Authentication:虽然我们不建议您使用 IIS 基本身份验证,但通过向 Git 请求添加额外的 header,您可以将 Git 与 IIS 基本身份验证一起使用:
You could open IIS Manager -> IIS -> Authentication
and check if the Basic Authentication is disabled.您可以打开IIS Manager -> IIS -> Authentication
并检查 Basic Authentication 是否被禁用。
On the other hand, you could remove the Azure DevOps Server related credentials from Credential Manager: Open the control panel on windows–> Click on User Accounts–> Click on Manage your Credentials–>Click on Windows Credentials
, locate the entry for your remote git repository–>Click on the item in the list and select Remove–> Finally try to use PAT again to clone a git Repo.另一方面,您可以从凭据管理器中删除 Azure DevOps Server 相关凭据:打开 Windows 上的control panel on windows–> Click on User Accounts–> Click on Manage your Credentials–>Click on Windows Credentials
,找到您的远程条目git repository-->点击列表中的项目和select Remove-->最后再次尝试使用PAT克隆一个git Repo。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.