Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create list of SSH tokens, personal access tokens by user name

GSHerber
Contributor
April 9, 2026

Does anyone have insight on how to create a list of SSH tokens, personal access tokens by user name in Bitbucket Data Center 9.4.18? I've tried several SQL scripts found online with AI but nothing works or produces data. Rest API maybe? 

Any help would be welcome.

1 answer

0 votes
Arkadiusz Wroblewski
Community Champion
April 10, 2026

Hello @GSHerber 

Yep, for this stop chasing SQL and use the supported REST endpoints instead.

Also one small wording point: in Bitbucket DC these are SSH keys, not really “SSH tokens”.

For the two user-level items you want, Atlassian documents these endpoints:

- personal HTTP tokens:
GET /rest/access-tokens/latest/users/{userSlug}
- personal SSH keys:
GET /rest/ssh/latest/keys?userName={userName}

  • get your users from the admin user list
  • loop through them
  • call the HTTP token endpoint per user
  • call the SSH key endpoint per user
  • write the result out to CSV/JSON.

One thing to watch for, I found a related Community thread where someone queried the SSH endpoint and got an empty result, so I would test the SSH call with a known user first before you build the full report.

 

Mehul Chauhan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 31, 2026

Hi 

For Bitbucket Data Center 9.4.18, the REST API is your best bet, as previously suggested by Arkadiusz Wroblewski. Here's how to approach it:

SSH Keys

Use the REST API endpoint:

  

GET /rest/ssh/1.0/keys?user={username}

To list all users' SSH keys, you can iterate over users:

# Get all users first
curl -u admin:password "https://your-bitbucket.com/rest/api/latest/admin/users?limit=1000"

# Then for each user, get their SSH keys

curl -u admin:password "https://your-bitbucket.com/rest/ssh/1.0/keys?user={username}"

Personal Access Tokens (HTTP Access Tokens)

For PATs, use:

 # List all tokens for a specific user (requires admin)

curl -u admin:password "https://your-bitbucket.com/rest/access-tokens/1.0/users/{username}"

Script to List All Users' Tokens

#!/bin/bash

BASE_URL="https://your-bitbucket.com"

AUTH="admin:password"

# Get all users (paginate if needed)

users=$(curl -s -u "$AUTH" "$BASE_URL/rest/api/latest/admin/users?limit=1000" | jq -r '.values[].name')

echo "User,SSH Keys,Access Tokens"

for user in $users; do

  ssh_count=$(curl -s -u "$AUTH" "$BASE_URL/rest/ssh/1.0/keys?user=$user" | jq '.size')

  pat_count=$(curl -s -u "$AUTH" "$BASE_URL/rest/access-tokens/1.0/users/$user" | jq '.size')

  echo "$user,$ssh_count,$pat_count"

done

I hope this helps.

Regards,

Mehul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
9.4.18
TAGS
AUG Leaders

Atlassian Community Events