Azure DevOps: “I can’t paste my PAT in the command line” — and what to do when PAT creation is restricted
If you’re trying to automate Azure DevOps tasks (like creating a Git repository) via command line, you’ll often end up here:
- You run
az devops login - It prompts for a Personal Access Token (PAT)
- You paste… and nothing appears
- Or your organization blocks PAT creation entirely with a policy
This article covers both problems:
- Why you can’t “see” the PAT when pasting (and how to authenticate reliably)
- What the “PAT creation restricted / allowlist required” message means
- Why SSH helps for Git push/pull but doesn’t replace PAT/OAuth for CLI operations
1) The “I pasted my PAT but nothing shows up” is often normal
When you run:
az devops login
the prompt accepts a token, but many terminals do not echo characters for secrets. That means:
- you paste the PAT
- the screen looks unchanged
- but the token may have been entered correctly
Microsoft documents PAT login for the Azure DevOps CLI and explicitly supports non-interactive methods (piping/env var) when interactive entry is inconvenient. (Microsoft Learn)
Quick verification after login
Immediately test your session:
az devops project list
If it lists projects, your login worked.
2) Reliable ways to authenticate without “pasting into the prompt”
Option A — Pipe the PAT to stdin (recommended when paste is annoying)
PowerShell (Windows):
"YOUR_PAT_HERE" | az devops login
bash (Git Bash / WSL):
echo "YOUR_PAT_HERE" | az devops login
This is a supported method in the official docs. (Microsoft Learn)
Option B — Use the AZURE_DEVOPS_EXT_PAT environment variable
This avoids az devops login entirely for many workflows:
PowerShell:
$env:AZURE_DEVOPS_EXT_PAT = "YOUR_PAT_HERE"az devops project list
This is also documented by Microsoft for the Azure DevOps CLI extension. (Microsoft Learn)
Tip: In automation, prefer a secure secret store (CI secret variables / vault) rather than hardcoding.
3) If your org restricts PAT creation: why your PAT “doesn’t exist” (even if you try to paste it)
If you see a message like:
“Your ability to create and regenerate personal access tokens (PATs) is restricted… You must be on the organization’s allowlist…”
That’s not a terminal issue. It’s a policy applied by your Azure DevOps tenant/org.
Microsoft now provides tenant and organization policies that can restrict PAT creation, scope, and lifespan. (Microsoft Learn)
There’s also an org policy that can prevent PAT creation/regeneration unless a user is explicitly allowlisted. (Microsoft for Developers)
What this means in practice
- You may be unable to create a new PAT at all
- You may be unable to regenerate existing PATs
- Existing PATs remain valid until they expire (depending on policy), but you can’t renew them without being allowlisted (Microsoft Learn)
Admin-side fix (the “correct” approach)
If you (or your admin) control the org:
- Keep restrictions enabled
- Add specific users/groups to the allowlist (least privilege)
This is the model Microsoft describes for secure PAT governance. (Microsoft Learn)
4) Creating a repo via command line typically requires Azure DevOps CLI auth (PAT/OAuth), not SSH
To create a repo with the Azure DevOps CLI, the command is:
az repos create --name "mouse-recorder"
That command is part of the azure-devops extension and requires authentication to Azure DevOps. (Microsoft Learn)
Why SSH won’t solve “create repo via CLI”
SSH is great for Git operations:
git clonegit pushgit pull
Azure Repos supports SSH key authentication for Git. (Microsoft Learn)
But SSH keys do not authenticate the Azure DevOps CLI to call org APIs like “create repository.” For that, you typically need PAT or modern OAuth/Entra methods (depending on your org setup). Microsoft’s auth guidance increasingly recommends Microsoft Entra OAuth tokens over PATs. (Microsoft Learn)
5) The practical workflow when PATs are restricted
If your organization blocks PAT creation and you still need to ship code:
Fast path: create the repo in the portal, use SSH for Git
- Create the repo in Azure DevOps UI (Repos → New repository)
- Use SSH keys to clone/push from your machine (Microsoft Learn)
Automation path: ask for allowlist or move to Entra-based auth
- Request allowlisting for PAT creation (preferably limited scope + short lifetime) (Microsoft Learn)
- Or adopt Microsoft Entra OAuth / managed identities where applicable (recommended direction) (Microsoft Learn)
6) Troubleshooting checklist (Windows-focused)
If paste doesn’t work in your terminal
- Windows Terminal / PowerShell:
Ctrl+Vusually works - Legacy CMD: right-click paste is often more reliable
- Git Bash: right-click or
Shift+Insert
If login still fails after “successful paste”
Run:
az devops project list
- If you get 401/403: token invalid, expired, wrong org, or policy blocks it.
- If you see the “restricted by organization” message: you need allowlisting or a non-PAT auth path. (Microsoft Learn)
Conclusion
- If the PAT doesn’t show while you paste: that can be normal (hidden input).
- If you want a no-drama login: use stdin piping or
AZURE_DEVOPS_EXT_PAT. (Microsoft Learn) - If PAT creation is restricted: it’s a policy and must be resolved by allowlisting or switching to Entra-based auth. (Microsoft Learn)
- SSH helps for Git, not for creating repos via CLI. (Microsoft Learn)
