Generate passwords and secret keys from shell

Everybody who needs to use from time to time some kind of secret keys or passwords with a minimal size and a combination of numbers, letters, lower and upper case and special characters, knows the pain in the ass to generate one.

But if you use linux like I do, it could be quite easy. If you need some passwords or secret keys, you can use (at a debian based host) the package called apg

apt-get install apg

With that tool it is possible to generate random passwords with a configurable length, enable or disabled special characters and all the other stuff which would be nice.

Example:

apg -a 1 -M sncl -n 1 -m 30

What do that options mean?

-a 1 specifies to use random characters. With -M sncl we set the symbolsets which should be used:

  • s generator should use special symbol
  • n generator should use numeral symbol
  • n generator should use capital symbol
  • l generator should use small letters symbol

-n 1 and -m 30 specify how many passwords should be created (-n) and how much characters should be used (-m).

With that options we get an output similar to the following:

A;G9qR'`#v{\3@WWbIx"$J^\$X#0_t

More information can be found on the man page

man apg
comments powered by Disqus