It was a simple sqlplus command meant to pull a routine report from Oracle Database. But the output had to be encrypted before it could leave the server, and the gpg step kept breaking. Logs said nothing useful. The pipeline stalled. Delivery missed its SLA.
Working with GPG and SQL*Plus isn’t exotic, but it demands precision. You can’t just chain commands and hope they work under load or in CI/CD. The trick is to handle authentication, environment variables, and process piping in a way that’s repeatable and secure.
Step One: Understand sqlplus Output
sqlplus -s gives you silent mode. Use it to turn off banners and headers. Add SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF to get clean output without artifacts. This matters because GPG will encrypt exactly what it gets — stray characters corrupt files.
Step Two: Secure Keys Before You Encrypt
GPG needs its keyring. Load it in an isolated environment with permissions locked down. Avoid hardcoding passphrases. Use --batch --yes --passphrase-file only if the secret is injected at runtime from a secure store. On shared servers, ensure the GNUPGHOME path is private.