|
1 | 1 | --- |
2 | 2 | ms.subservice: azure-devops-ecosystem |
3 | 3 | ms.topic: conceptual |
4 | | -title: Use the Cross-platform CLI for Azure DevOps |
5 | | -description: Use the Cross-platform CLI for Azure DevOps, using personal access tokens (PATs). |
| 4 | +title: Cross-platform CLI authentication for Azure DevOps |
| 5 | +description: Learn authentication options for the cross-platform CLI for Azure DevOps, including Microsoft Entra ID tokens and personal access tokens. |
6 | 6 | ms.assetid: 6dc7f977-4b62-4bd6-b77a-1c6cade1ffa8 |
7 | 7 | monikerRange: '<= azure-devops' |
8 | 8 | ms.author: chcomley |
9 | 9 | author: chcomley |
10 | | -ms.date: 11/10/2023 |
| 10 | +ms.date: 07/14/2025 |
11 | 11 | --- |
12 | 12 |
|
13 | | -# Use the Cross-platform CLI for Azure DevOps using personal access tokens |
| 13 | +# Cross-platform CLI authentication for Azure DevOps |
14 | 14 |
|
15 | 15 | [!INCLUDE [version-lt-eq-azure-devops](../../../includes/version-lt-eq-azure-devops.md)] |
16 | 16 |
|
17 | | -Use personal access tokens (PATs) with the cross-platform CLI for Azure DevOps. |
| 17 | +This article explains authentication approaches for the cross-platform CLI (tfx-cli) and Azure DevOps. |
18 | 18 |
|
19 | 19 | > [!IMPORTANT] |
20 | | -> We don't recommend using basic authentication or PATs. Instead, we recommend using [Microsoft Entra-based authentication](../authentication/entra.md), if you're interacting with Microsoft Entra accounts. |
| 20 | +> We recommend using [Microsoft Entra ID authentication](../authentication/entra.md) as the primary method for authentication. Personal access tokens (PATs) should be used only when Microsoft Entra ID authentication isn't available. Basic authentication is deprecated and not recommended. |
21 | 21 |
|
22 | 22 | ## Prerequisites |
23 | 23 |
|
24 | | -- Latest version of [**Node.js source code**](https://nodejs.org/en/download/) |
25 | | -- **Cross-platform CLI for Azure DevOps** |
26 | | - - Install **tfx-cli** using `npm`, a component of Node.js by running: |
| 24 | +Before you begin, ensure you have: |
27 | 25 |
|
28 | | - ```no-highlight |
29 | | - npm i -g tfx-cli |
| 26 | +- [Node.js](https://nodejs.org/en/download/) (latest LTS version recommended) |
| 27 | +- **tfx-cli** installed globally: |
| 28 | + |
| 29 | + ```bash |
| 30 | + npm install -g tfx-cli |
30 | 31 | ``` |
31 | 32 |
|
32 | | - For more information about **tfx-cli**, see the [Node CLI for Azure DevOps on GitHub](https://github.com/Microsoft/tfs-cli). |
| 33 | +For more information about tfx-cli, see the [Node CLI for Azure DevOps on GitHub](https://github.com/Microsoft/tfs-cli). |
33 | 34 |
|
34 | | -## Personal access token |
| 35 | +## Authentication methods |
35 | 36 |
|
36 | | -Create a personal access token and paste it into the sign-in command. |
| 37 | +Choose the appropriate authentication method based on your environment: |
37 | 38 |
|
38 | | -``` |
39 | | -~$ tfx login |
40 | | -Copyright Microsoft Corporation |
| 39 | +| Method | Recommended for | |
| 40 | +|--------|----------------| |
| 41 | +| Microsoft Entra ID | Azure DevOps Services | |
| 42 | +| PAT | Azure DevOps Server, automation scripts | |
| 43 | +| Basic Authentication | Azure DevOps Server only | |
41 | 44 |
|
42 | | -> Service URL: {url} |
43 | | -> Personal access token: xxxxxxxxxxxx |
44 | | -Logged in successfully |
| 45 | +## Microsoft Entra ID authentication (Recommended) |
| 46 | + |
| 47 | +For Azure DevOps Services, use Microsoft Entra ID authentication for the best security: |
| 48 | + |
| 49 | +```bash |
| 50 | +tfx login |
45 | 51 | ``` |
46 | 52 |
|
47 | | -See the following examples of valid URLs: |
| 53 | +When prompted: |
| 54 | +1. Enter your service URL, for example, `https://dev.azure.com/Your_Organization`. |
| 55 | +2. Follow the browser-based authentication flow. |
| 56 | +3. Complete the sign-in process in your browser. |
48 | 57 |
|
49 | | -- `https://marketplace.visualstudio.com` |
50 | | -- `https://youraccount.visualstudio.com/DefaultCollection` |
| 58 | +For detailed guidance on Microsoft Entra ID authentication, see [Microsoft Entra-based authentication](../authentication/entra.md). |
51 | 59 |
|
52 | | -## Configure for Basic authentication |
| 60 | +## PAT authentication |
53 | 61 |
|
54 | | -> [!WARNING] |
55 | | -> We don't recommend basic authentication. Turning on IIS basic authentication causes various issues, and you should use [personal access tokens (PATs)](../../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) instead. For example, if you turn on IIS basic authentication, GIT command line stops working. |
| 62 | +Use PATs when Microsoft Entra ID authentication isn't available, such as with Azure DevOps Server. |
56 | 63 |
|
57 | | -Follow these steps to enable basic auth for your Azure DevOps instance: |
| 64 | +### Create and use a PAT |
58 | 65 |
|
59 | | -> [!WARNING] |
60 | | -> Basic authentication sends usernames and passwords in plaintext. Consider [configuring Azure DevOps Server to use SSL](/azure/devops/server/admin/setup-secure-sockets-layer) to enable secure communication when using basic auth. |
| 66 | +1. [Create a PAT](../../../organizations/accounts/use-personal-access-tokens-to-authenticate.md) with the required scopes. |
| 67 | +2. Sign in using the PAT: |
61 | 68 |
|
62 | | -1. Install the `Basic Authentication` feature for IIS in Server Manager. |
| 69 | + ```bash |
| 70 | + tfx login |
| 71 | + ``` |
63 | 72 |
|
64 | | - > [!div class="mx-imgBorder"] |
65 | | - >  |
| 73 | +3. When prompted, provide: |
| 74 | + - **Service URL**: Your Azure DevOps instance URL. |
| 75 | + - **Personal access token**: The PAT you created. |
66 | 76 |
|
67 | | -2. Open IIS Manager and expand to the `Azure DevOps Server` website, double-click the `Authentication` tile in the Features view. |
| 77 | +**Example URLs:** |
| 78 | +- Azure DevOps Services: `https://dev.azure.com/Your_Organization` |
| 79 | +- Azure DevOps Server: `https://yourserver/tfs/DefaultCollection` |
| 80 | +- Visual Studio Marketplace: `https://marketplace.visualstudio.com` |
68 | 81 |
|
69 | | -3. Choose `Basic Authentication` in the list of authentication methods. Choose `Enable` in the right hand column. You should now see `Basic Authentication` enabled. |
| 82 | +**Example session:** |
| 83 | +``` |
| 84 | +~$ tfx login |
| 85 | +Copyright Microsoft Corporation |
70 | 86 |
|
71 | | -> [!NOTE] |
72 | | -> Leave the **domain** and **realm** settings for Basic Authentication empty. |
| 87 | +> Service URL: https://dev.azure.com/Your_Organization |
| 88 | +> Personal access token: ********************** |
| 89 | +Logged in successfully |
| 90 | +``` |
73 | 91 |
|
74 | | -## tfx sign in with Basic authentication |
| 92 | +## Basic authentication (Deprecated) |
75 | 93 |
|
76 | | -Now you can start to use `tfx` against your server. Sign in before you issue commands. |
| 94 | +> [!WARNING] |
| 95 | +> Basic authentication is deprecated and not recommended. Use Microsoft Entra ID instead. Basic authentication: |
| 96 | +> - Sends credentials in plaintext |
| 97 | +> - Can cause issues with Git command line operations |
| 98 | +> - Poses security risks |
77 | 99 |
|
78 | | -1. Enter the following command: |
| 100 | +### Configure basic authentication (Azure DevOps Server only) |
79 | 101 |
|
80 | | - ```no-highlight |
81 | | - tfx login --auth-type basic |
82 | | - ``` |
| 102 | +If you must use basic authentication with Azure DevOps Server installations: |
83 | 103 |
|
84 | | -2. Add your service url. |
85 | | -3. Add your username. Use `domain\user` (for example, fabrikam\peter). If you're working on a workgroup machine, use `machinename\user`. |
86 | | -4. Add your password. Enter the password for the username that you previously entered. |
| 104 | +1. **Enable IIS Basic Authentication:** |
| 105 | + - Open Server Manager. |
| 106 | + - Install the Basic Authentication feature for IIS. |
| 107 | + - In IIS Manager, go to your Azure DevOps Server website. |
| 108 | + - Double-select **Authentication** in the Features view. |
| 109 | + - Enable Basic Authentication. |
| 110 | + - Leave domain and realm settings empty. |
87 | 111 |
|
88 | | -**You can now use any other tfx command.** |
| 112 | +2. **Sign in with basic authentication:** |
89 | 113 |
|
90 | | -```no-highlight |
91 | | -> tfx login --auth-type basic |
92 | | -Copyright Microsoft Corporation |
| 114 | + ```bash |
| 115 | + tfx login --auth-type basic |
| 116 | + ``` |
93 | 117 |
|
94 | | -Enter service url > http://localhost:8080/tfs/defaultcollection |
95 | | -Enter username > fabfiber\peter |
96 | | -Enter password > ******* |
97 | | -logged in successfully |
98 | | -``` |
| 118 | +3. When prompted, provide: |
| 119 | + - **Service URL**: Your on-premises server URL (for example, `http://yourserver:8080/tfs/DefaultCollection`). |
| 120 | + - **Username**: Use `domain\username` format (for example, `fabrikam\john`) |
| 121 | + - **Password**: Your domain password. |
| 122 | +
|
| 123 | +> [!TIP] |
| 124 | +> Consider [configuring SSL](/azure/devops/server/admin/setup-secure-sockets-layer) for secure communication when using basic authentication. |
| 125 | +
|
| 126 | +## Next step |
| 127 | +
|
| 128 | +> [!div class="nextstepaction"] |
| 129 | +> [View the complete tfx-cli command reference](https://github.com/Microsoft/tfs-cli) |
0 commit comments