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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-08-2005, 03:13 PM
|
#1
|
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:
|
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.
|
|
|
01-08-2005, 03:29 PM
|
#2
|
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290
|
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 03:30 PM.
|
|
|
01-08-2005, 03:30 PM
|
#3
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
01-08-2005, 07:25 PM
|
#4
|
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:
|
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.
|
|
|
01-08-2005, 09:10 PM
|
#5
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625
Rep:
|
You might find this thread helpful.
|
|
|
01-08-2005, 10:21 PM
|
#6
|
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:
|
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.
|
|
|
All times are GMT -5. The time now is 11:59 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|