Hi,
crypt() is not a function that you can use in bash, it is a c(++) function. If you want to use it you need to write a little c (or c++) script around it. After compiling you'll end up with a binary that can produce the encrypted password needed by useradd's -p option.
This rough example creates md5 encrypted passwords:
Code:
#define _XOPEN_SOURCE
#include <stdio.h>
#include <unistd.h>
int main (int argc, char* argv[])
{
char *result;
printf ("%s\n", crypt (argv[1], "$1$"));
return (0);
}
/* gcc -lcrypt md5.crypt.c -o md5.crypt */
Save it as
md5.crypt.c . After compiling it with:
gcc -lcrypt md5.crypt.c -o md5.crypt, you'll end up with
md5.crypt
An example run:
Code:
$ ./md5.crypt FooBar
$1$$yNWeilBBQ6tKlG4nsnV9W.
Hope this helps.