LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2005, 02:13 PM   #1
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Rep: Reputation: 30
Adding Users with the "-p" option


I was wondering if there were a special way of adding users with the -p option (passwd option).

I am writing a script that needs to add 100 users at the end of a kickstart installation and cannot input the password for each directly.

I have tried useradd -p <clear text passwd here> <user acct here>.

But when I try to login the password is incorrect. I am sure that I have missed something in the man page for useradd. And I know it probably has something to do with "crypt". But I cannot figure out what.

Thanks for all the help.
 
Old 01-08-2005, 02:29 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Yes, you must specified the encrypted password, not the plaintext password. Here's a handy Perl script to generate the useradd command for a list of usernames and passwords (one entry per line, usernames and password separated by a space). WARNING: this is not tested.

Code:
#!/usr/bin/perl

while(chomp($line = <STDIN>)) {
  ($unme,$passwd) = split(' ', $line);

  # create a random salt, from perldoc -f crypt
  $salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64];
  $encp = crypt($passwd,$salt);
  print "useradd -p $encp $unme\n";
}
An alternative on a bunch of similar boxes is to create all the accounts on one machine and copy the password and shadow files over, or use NIS or LDAP for distributed authentication.

Last edited by btmiller; 01-08-2005 at 02:30 PM.
 
Old 01-08-2005, 02:30 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

The -p option needs an already encrypted password. Take a look here:

http://www.linuxquestions.org/questi...hreadid=255560

There are probably more threads concerning this issue floating around.

Hope this helps.
 
Old 01-08-2005, 06:25 PM   #4
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Original Poster
Rep: Reputation: 30
Thanks for the replies. I read all the links, and nothing from them worked out. I did not try the perl script above simply because I am not sure how that will work out with the rest of the script. (The rest of the script is BASH commands only, and as I stated before this is going to be a post-install script for a Kickstart install. I don't think I can change interpreters during the process...could be wrong though, I am new to KS Installs as well.). However, those articles and that perl script above did get my head moving again. This is what I came up with.

1. On the local NFS server (the one where my script is held anyways). I created a local user account with the password I wanted for the above mentioned 100 users. (no worries about security here, the Install server only gets hooked to the network when it is needed. It also only gets hooked up to rooms that it need to via a VLAN. Otherwise it is locked in the server closet, powered down and disconnected).

2. Then a simple:
Code:
 /usr/sbin/useradd -p `cat /etc/shadow | grep <my server username here> | cut -d: -f2` <workstation account name here>
Again thanks for all the help. This really got my brain going again.
 
Old 01-08-2005, 08:10 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
You might find this thread helpful.
 
Old 01-08-2005, 09:21 PM   #6
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Original Poster
Rep: Reputation: 30
Yeah, I read that thread. The encrypt that came out of openssl was off by 3 characters thus the passwords did not match up. I didn't do too much investigating after that though.

Thanks for the additional help.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
"adduser" not adding users to default group "users" PunkPT Slackware 2 09-23-2004 11:50 AM
suse 9.0 "adding and removing users" Virtualhate Linux - Newbie 5 06-09-2004 10:50 PM
XF86Config : Option "Resolution" "800" carboncopy Slackware 2 12-16-2003 10:13 PM
anging "Protocol" option to "IMPS/2" in XF86Config-4 causes problems zstingx Linux - General 2 10-27-2003 09:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:44 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
Open Source Consulting | Domain Registration