[Previo por Fecha] [Siguiente por Fecha] [Previo por Hilo] [Siguiente por Hilo]
[Hilos de Discusión] [Fecha] [Tema] [Autor]On Thu, 16 Dec 1999, Jordi Adame (K40N3R) wrote: > Hola. > > Como le puedo hacer para ke cuando haga useradd pueda especificar un > password > hago esto: > > useradd usuario -p password > pero en /etc/shadow me pone > usuario:password:..... > en vez de codificarmelo. useradd(8) espera que el parametro <password> de -p sea el password ya encriptado. Puedes usar algo como: # useradd usuario -p `cryptpw password` de forma que cryptpw(8) te encripte primero el password. Cómo? No tienes instalado cryptpw? OK, como el rpm correspondiente es un poco dificil de conseguir, abajo encuentras el código fuente sacado directamente de mi distribución favorita: MSG Enhanced Linux ;-) Saludos Salvador Ortiz ============= genpw.c ============= /* * cryptpw v1.0 * Copyright (c) 1999 Salvador Ortiz Garcia <sog en msg com mx> * This program is under the terms of the GNU GENERAL PUBLIC LICENSE * * cryptpw is a _simple_ stand alone program for generate encrypted * passwords in the same way that glibc2 based linux systems. * * It takes a clear text password and returns the encrypted one * suitable for insertion in /etc/password, /etc/shadow, .htaccess, etc. * or for use in the '-p' parameter of useradd(8) * * For compiling use: * gcc -o cryptpw -lcrypt cryptpw.c */ #define _XOPEN_SOURCE #include <stdlib.h> #include <sys/time.h> #include <unistd.h> int md5=0; char *crypt_make_salt(void) { struct timeval tv; static char result[40]; result[0] = '\0'; if(md5) { strcpy(result, "$1$"); /* magic for the new MD5 crypt() */ } /* * Generate 8 chars of salt, the old crypt() will use only first 2. */ gettimeofday(&tv, (struct timezone *) 0); strcat(result, l64a(tv.tv_usec)); strcat(result, l64a(tv.tv_sec + getpid() + clock())); if (strlen(result) > 3 + 8) /* magic+salt */ result[11] = '\0'; return result; } void usage(char *myname) { printf("Usage: %s [-md5] <passwd>\n" "\t-md5 Use new MD5_CRYPT method\n" "\t<passwd> Clear text password\n",myname); exit(1); } int main(int argc, char *argv[]) { int argp = 1; if(argc < 2) usage(argv[0]); if(!strcmp(argv[1],"-md5")) { md5=1; argp++; } if(argp >= argc) usage(argv[0]); printf("%s\n",crypt(argv[argp],crypt_make_salt())); exit(0); } -- Para desuscribirse, mande correo a: ayuda-unsubscribe en linux org mx Para comandos adicionales, envíelo a: ayuda-help en linux org mx