How to generate JSON with random password with pwgen and bash

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

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

Example output

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

 


Check out similar posts by category: Linux