Skip to main content
  1. Posts/

apg.pl - A "Automated Password Generator" clone

·355 words·2 mins

APG (short for “Automated Password Generator”) is a little tool that I’ve been using for decades now, to generate secure and random passwords on my UNIX systems (i. e. in scripts or stuff like that). Unfortunately APG hasn’t been maintained since 2003 and more and more Unix distributions are abondoning the tool. So I was looking for an alternative. FreeBSD’s “pkg” recommends " security/makepasswd", which is a password generator tool written in Perl but requires a lot of dependency packages and doesn’t offer the feature-set/flexibility of APG.

apg.pl #

Therefore I decided to write my own implementation… introducing: apg.pl. It’s a simple Perl script with a small dependency footprint, that is similar to the original APG. As I never used APG’s “pronouncable password” functionality, I left this out in my version, though.

Small footprint #

apg.pl “only” requies Perl 5.12 (or higher) and the CryptX CPAN package, which should be available in most Linux and BSD distributions. I tried to clone most of APGs CLI options but did not 100% follow the original, as I though that some options were much to complicated in APG.

CLI options available #

  • -m, --minpasslen <length>: The minimum length of the password to be generated
  • -x, --maxpasslen <length>: The maximum length of the password to be generated
  • -n, --numofpass <number of passwords>: The amount of passwords to be generated
  • -E, --exclude <list of characters>: Do not use the specified characters in generated passwords
  • -U, --uppercase: Use uppercase characters in passwords
  • -N, --numbers: Use numeric characters in passwords
  • -S, --special: Use special characters in passwords
  • -H, --human: Avoid ambiguous characters in passwords (i. e.: 1, l, I, o, O, 0)
  • -c, --complex: Generate complex passwords (implies -U -N -S and disables -H)
  • -h, --help: Show a CLI help text
  • -v, --version: Show the version number

apg.pl is FOSS #

I released apg.pl under the MIT license in a public repo on Github.com. So feel free to use the software and enhance it to your liking. PR are welcome.

Docker #

Update 2021-02-17: Yeah… you can use it with Docker as well. There is a ready to use image on DockerHub.