LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   shell script user not ok (https://www.linuxquestions.org/questions/linux-general-1/shell-script-user-not-ok-75317/)

slam 07-23-2003 05:10 PM

shell script user not ok
 
I'm trying to use a shell script that creates users based off a list
ie my text file is
joe hispass
jane herpass

it parses the text file and does
adduser joe -p hispass
then
adduser jane -p herpass

seemed to work fine..
After going into the user gui
I see all the names
but if I try to login ie telnet with a new name it wont login
I delete the username and add it in the gui and its fine?

any ideas?
redhat 8

lyle_s 07-23-2003 05:40 PM

The -p option on useradd is expecting the encrypted password (see man useradd). So the password is being set to something you're not expecting.

One thing you could try is running passwd using "here documents" in your script something like this (not tested):

passwd "$USER" <<EOF
"$PASSWORD"
"$PASSWORD"
EOF

or something to that effect.

Lyle

slam 07-23-2003 05:56 PM

thanks
 
didn't think about encryption:scratch: silly me. ok onward we go

ovf 07-23-2003 06:57 PM

Here's a little 'C' program to encrypt passwords in case you want to add encrypted passwords to the shell script. It was tested under RedHat 9.0

/*
* cryptit.c
*
* simple program to encrypt 8 character passwords.
*
* compile command: gcc -lcrypt -o cryptit cryptit.c
*/
#include <unistd.h>
#include <stdio.h>

char seed [2];
char seedstart [3] = {'0', 'a', 'A'};

void setseed (void)
{
int i;

for (i=0; i < 2; i++) {
seed[i] = seedstart[random() % 3];
seed[i] += random() % (seed[i] == '0' ? 10 : 26);
}

}

main ()
{

char passwd[9];
char *cpasswd;

while (1) {
printf("Password (8 characters max.): ");
scanf ("%8s",passwd);
setseed();
cpasswd = crypt(passwd, seed);
printf ("The encrypted password for %s is %s\n", passwd, cpasswd);
}

}

Edit: added random seed generation.

DIYLinux 07-24-2003 06:40 AM

Dont use a fixed salt with crypt. See todays www.slashdot.org for the LanManager password vulnerability, which allows Windows passwords to be cracked in 11.3 seconds.


All times are GMT -5. The time now is 01:54 PM.