How to generate JSON with random password with pwgen and bash

This script will generate a random password stored in a JSON file:

generate_secret_json.sh
echo "{\"secret\": \"$(pwgen 30 1)\"}" > secret.json

Example output

secret.json
{"secret": "thie2uv6Ro3cah2oodohx2vai5Ahka"}

 


Check out similar posts by category: Linux