Skip to content

Instantly share code, notes, and snippets.

@rjhornsby
Created September 30, 2025 15:26
Show Gist options
  • Save rjhornsby/b3722387e86f60296e78af4ae5f4ab7b to your computer and use it in GitHub Desktop.
Save rjhornsby/b3722387e86f60296e78af4ae5f4ab7b to your computer and use it in GitHub Desktop.
Get CAC/PIV UPN on macOS
system_profiler SPSmartCardsDataType | grep -A5 '#04: Kind: private RSA' | tail -n3 \
| openssl x509 -noout -text | grep -o 'UPN:.*,' | awk -F'[:,]' '{print $2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment