Access Keychain Access password generator (password assistant) via Terminal without the user interface

Is it possible to access, the "password assistant" also known as the password generator located inside the Keychain Access via terminal or otherwise?

Steps to access in UI:

  • Launch Keychain Access
  • New password item
  • Select padlock item (generate password)
  • Create random password according to security level

Solution 1:

Your exact question has been asked on Stackoverflow in 2009. The answers did not provide a way to access the Keychain password generator, but did suggest some alternatives.

A Google search for mac terminal password generator also shows several ways to generate a password from Terminal. I have listed a couple below.

openssl rand -base64 6

You can change -base64 to -hex to limit the use of special characters. The 6 indicates the lenght of the password.

env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" < /dev/urandom | head -c 10

The "a-zA-Z0-9-_\$\?" part indicates allowed characters and the 10 defines the length.