简体   繁体   English

使用访问令牌从 Azure DevOps 服务器(本地)克隆 git

[英]Clone git from Azure DevOps Server (on-prem) using access token

I have an Azure DevOps Server instance installed on a Windows Server 2019 machine: https://tfs.acme.com我在 Windows Server 2019 机器上安装了一个 Azure DevOps Server 实例: https ://tfs.acme.com

I'm trying to clone a repository using a personal access token.我正在尝试使用个人访问令牌克隆存储库。 I managed to clone the repository using my NTLM login password, but not using the token ( fatal: Authentication failed ).我设法使用我的 NTLM 登录密码克隆了存储库,但没有使用令牌( fatal: Authentication failed )。

I enabled all possible scopes when generating the token and it works fine for all API calls I've tried.我在生成令牌时启用了所有可能的范围,它适用于我尝试过的所有 API 调用。

开发运维

Is there any additional configuration for cloning with token?是否有任何其他配置用于使用令牌进行克隆? Another method that will allow me to use same password for both API and clone?另一种允许我对 API 和克隆使用相同密码的方法? (NTLM password fails on Rest API calls). (NTLM 密码在 Rest API 调用上失败)。

This worked for me: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Linux#use-a-pat这对我有用: https ://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Linux#use-a -拍

Linux: Linux:

MY_PAT=yourPAT # replace "yourPAT" with ":PatStringFromWebUI"
B64_PAT=$(printf "%s"":$MY_PAT" | base64)
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName

Windows:视窗:

$MyPat = ':PatStringFromWebUI'
$UserName = ':UserNameToUseWithToken'
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("$UserName:$MyPat"))
git -c http.extraHeader="Authorization: Basic $B64Pat" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您可以使用 Azure Devops Server 存储库中的 ssh 进行 git clone 吗? - Can you git clone with ssh from Azure Devops Server repos? Visual Studio 代码:无法在本地 DevOps 中打开 Git 存储库 - Visual Studio Code: unable to open Git repository in on-prem DevOps 使用 java 从 Azure devops 将 git 存储库克隆到本地 - Clone a git repository to local from Azure devops using java 无法使用 PAT 从 Azure DevOps 克隆 git - Cannot clone git from Azure DevOps using PAT 如何使用 PowerShell 任务 (git clone) 在 Azure DevOps Server 发布管道中运行 Git 命令 - How to run Git commands in Azure DevOps Server release pipeline using PowerShell tasks (git clone) 如何在 Azure DevOPS 服务器上使用 PAT 克隆 git 存储库 - How to use PAT on Azure DevOPS Server to clone a git repo 使用 git clone 命令从 azure devops 检出多个存储库时出错 - Error in checking out multiple repository from azure devops using git clone command Azure DevOps:使用“git clone”的 Powershell 管道无法正常工作 - Azure DevOps: Pipeline with Powershell using "git clone" not working git 从 Azure 克隆 DevOps 返回“没有这样的设备或地址”错误 - git clone from Azure DevOps returns "No such device or address" error 有没有办法按计划自动将 Azure DevOps 的 Git 存储库克隆到本地? - Is there a way to automatically clone the Git repositories from Azure DevOps to local with schedule?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM