Unix $5$ and $6$ hashes from the command line

  • Sun 06 September 2020
  • misc

Until recently I had been reliant on random Perl and Python one-liners to generate $5$ and $6$ hashes (as well as $1$ - AHEM, Juniper...) when I needed to email someone a password or set up Ansible for mail accounts on SmartOS.

Today I learned that OpenSSL 1.1.1 (2018) added appropriate flags to DTRT.

[root@ansible ~]# openssl passwd -1 -stdin
[root@ansible ~]# openssl passwd -5 -stdin
[root@ansible ~]# openssl passwd -6 -stdin
[root@ansible ~]# 

You can also specify the password on the command line, if you're the kind of person who likes to leave that kind of thing lying about in your .bash_history...