crypt(1) for the command line
Looks like there is no passwd-compatible crypt(1) for the command line. htpasswd, unfortunately, uses a different algorithm.
This short perl script might be a replacement:
#!/usr/bin/perl -w
use strict;
while(<>) {
my $seed = `apg -a 1 -m 8`;
chomp;
print crypt(“$_”, “\\$1\\$$seed”). “\\n”;
}
Or do we have something better already in the distribution?
Update: looks like mkpasswd (from the whois package, whatever makes it belong in there) does the job quite nicely, but the script shown above takes care of automatic salt creation as well. Any ideas how to do that more elegantly, without requireing apg?