LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 07-23-2003, 06:10 PM   #1
slam
Member
 
Registered: Mar 2003
Posts: 36

Rep: Reputation: 15
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
 
Old 07-23-2003, 06:40 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 388

Rep: Reputation: 52
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
 
Old 07-23-2003, 06:56 PM   #3
slam
Member
 
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 15
thanks

didn't think about encryption silly me. ok onward we go
 
Old 07-23-2003, 07:57 PM   #4
ovf
Member
 
Registered: Jul 2003
Location: Massachusetts
Distribution: LFS 4.0, Windows XP, Ubuntu 10.01, Gentoo 2.6.32-r7, OpenSolaris
Posts: 100

Rep: Reputation: 15
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.

Last edited by ovf; 07-24-2003 at 09:08 PM.
 
Old 07-24-2003, 07:40 AM   #5
DIYLinux
Member
 
Registered: Jul 2003
Location: NL
Distribution: My own
Posts: 92

Rep: Reputation: 17
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script user input tuckermaddox Linux - Newbie 5 08-12-2004 04:14 AM
Running script as user that does not have shell sschueller Linux - General 1 04-24-2004 04:06 PM
Shell script that changes user davholla Linux - General 2 03-23-2004 10:18 PM
changing user in a shell script sanjith11 Programming 6 03-22-2004 02:18 PM
Add User Shell Script DAC Programming 2 10-13-2002 04:12 PM


All times are GMT -5. The time now is 12:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration