Created
October 24, 2020 02:53
-
-
Save woodenphone/7f1d8b4fb5178d1514c8237bab12bc0b to your computer and use it in GitHub Desktop.
WIP script for smacking GPG on Win10 and multiple smartcards with when it plays up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## gpg_diagnose.ps1 | |
| ## Basic diagnostic/troubleshooting script for GPG | |
| ## By: "Ctrl-S" | |
| ## Created: 2020-10-20 | |
| ## Modified: 2020-10-21 | |
| ## == DIAGNOSE == | |
| Write-Host("== DIAGNOSE ==") | |
| Write-Host("DIAGNOSE: Resolve abspaths of noteworthy files") | |
| # Display path of GPG and other likely relevant programs | |
| where.exe gpg | |
| where.exe git | |
| where.exe putty | |
| Write-Host("DIAGNOSE: Check content of GPG conf files") | |
| # Check if certain files exist: | |
| # GNUPG config files | |
| Get-Content -Path "%APPDATA%\gnupg\gpg-agent.conf" | |
| Get-Content -Path "%APPDATA%\gnupg\scdaemon.conf" | |
| Write-Host("DIAGNOSE: List smartcards") | |
| gpg --card-status # Inspect smartcard. | |
| # List keys | |
| Write-Host("DIAGNOSE: List host public keys") | |
| gpg --list-keys | |
| Write-Host("DIAGNOSE: List host secret keys") | |
| gpg --list-secret-keys | |
| Write-Host("== /diagnose ==") | |
| ## == /DIAGNOSE == | |
| ## | |
| ## == REPAIR == | |
| ## Try to fix things | |
| Write-Host("== REPAIR ==") | |
| Write-Host("REPAIR: Resstart GPG") | |
| # Kill GPG. | |
| gpg-connect-agent killagent /bye | |
| # Start GPG. | |
| gpg-connect-agent "/bye" | |
| Start-Sleep -s 2 # Let task complete before anything else | |
| Write-Host("REPAIR: Associate with smartcard") | |
| # Associate with smartcard if present | |
| gpg-connect-agent "scd serialno" "learn --force" /bye | |
| Start-Sleep -s 2 # Let task complete before anything else | |
| ## == /REPAIR == | |
| Write-Host("== End of script ==") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment