Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 07-23-2003, 05:10 PM   #1
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
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, 05:40 PM   #2
Registered: Jul 2003
Distribution: Slackware
Posts: 389

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

or something to that effect.

Old 07-23-2003, 05:56 PM   #3
Registered: Mar 2003
Posts: 36

Original Poster
Rep: Reputation: 15

didn't think about encryption silly me. ok onward we go
Old 07-23-2003, 06:57 PM   #4
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);
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 08:08 PM.
Old 07-24-2003, 06:40 AM   #5
Registered: Jul 2003
Location: NL
Distribution: My own
Posts: 92

Rep: Reputation: 18
Dont use a fixed salt with crypt. See todays for the LanManager password vulnerability, which allows Windows passwords to be cracked in 11.3 seconds.


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 03:14 AM
Running script as user that does not have shell sschueller Linux - General 1 04-24-2004 03:06 PM
Shell script that changes user davholla Linux - General 2 03-23-2004 09:18 PM
changing user in a shell script sanjith11 Programming 6 03-22-2004 01:18 PM
Add User Shell Script DAC Programming 2 10-13-2002 03:12 PM > Forums > Linux Forums > Linux - General

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

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