Hi,
I need to setup a load of user accounts on a series of machines, for testing purposes. I'm using a script to do this, but the only problem I have so far: I have to activate them all manually by doing passwd user1, passwd user2, passwd user3, etcetera. The useradd man page mentions a -p option to define a password, but I can't seem to get this to work. Here's what I'd like to be able to do:
# useradd -c "Gaston Lagaffe" -p abc123 -m glagaffe
And put that line in a script, so the account is *instantly* activated. I tried it, but to no avail. Looks like there's some burning loop I have to jump through first :o)
No security considerations here for the moment, since it's for testing.
Any idea how this works?
Niki
On Thu, Jul 9, 2009 at 7:32 AM, Niki Kovacscontact@kikinovak.net wrote:
Hi,
I need to setup a load of user accounts on a series of machines, for testing purposes. I'm using a script to do this, but the only problem I have so far: I have to activate them all manually by doing passwd user1, passwd user2, passwd user3, etcetera. The useradd man page mentions a -p option to define a password, but I can't seem to get this to work. Here's what I'd like to be able to do:
# useradd -c "Gaston Lagaffe" -p abc123 -m glagaffe
And put that line in a script, so the account is *instantly* activated. I tried it, but to no avail. Looks like there's some burning loop I have to jump through first :o)
No security considerations here for the moment, since it's for testing.
Any idea how this works?
Niki _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
You can't set passwd like that. Rather try making a script which you can feed the user pass and other info. You can set password from shell like this:
echo 123abc|passwd --stdin username
# for user in user1 user2 user3 ; do useradd $user ; echo "password" | passwd --stdin $user ; done
cant make it any simpler
Sander
Lucian@lastdot.org wrote:
On Thu, Jul 9, 2009 at 7:32 AM, Niki Kovacscontact@kikinovak.net wrote:
Hi,
I need to setup a load of user accounts on a series of machines, for testing purposes. I'm using a script to do this, but the only problem I have so far: I have to activate them all manually by doing passwd user1, passwd user2, passwd user3, etcetera. The useradd man page mentions a -p option to define a password, but I can't seem to get this to work. Here's what I'd like to be able to do:
# useradd -c "Gaston Lagaffe" -p abc123 -m glagaffe
And put that line in a script, so the account is *instantly* activated. I tried it, but to no avail. Looks like there's some burning loop I have to jump through first :o)
No security considerations here for the moment, since it's for testing.
Any idea how this works?
Niki _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
You can't set passwd like that. Rather try making a script which you can feed the user pass and other info. You can set password from shell like this:
echo 123abc|passwd --stdin username _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Niki Kovacs wrote:
Hi,
I need to setup a load of user accounts on a series of machines, for testing purposes. I'm using a script to do this, but the only problem I have so far: I have to activate them all manually by doing passwd user1, passwd user2, passwd user3, etcetera. The useradd man page mentions a -p option to define a password, but I can't seem to get this to work. Here's what I'd like to be able to do:
# useradd -c "Gaston Lagaffe" -p abc123 -m glagaffe
And put that line in a script, so the account is *instantly* activated. I tried it, but to no avail. Looks like there's some burning loop I have to jump through first :o)
No security considerations here for the moment, since it's for testing.
Any idea how this works?
Niki _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi Niki,
I have a script called "usergen" that does this for 1 user at a time. You can wrap this in a loop and feed it a list of names for the accounts that you need to create.
The script is: PWD=`mkpasswd -l 8 -s 2`; export PWD echo "user = $1 password = $PWD" /usr/sbin/useradd -c "$2" -m -k /home/skeleton -n -p $PWD $1 echo $PWD| passwd --stdin $1
You can of course vary the parameters for password generation by changing the length (-l) and allowing special characters etc.
The directory /home/skeleton contains all the files that you need to set up in each user's account. This can also be a customized .bashrc to set environmental variables etc. The line with the echo command is there so that you have a record of the password generated for each user.
Hope this helps
ChrisG
On Thu, 2009-07-09 at 08:32 +0200, Niki Kovacs wrote:
Hi,
I need to setup a load of user accounts on a series of machines, for testing purposes. I'm using a script to do this, but the only problem I have so far: I have to activate them all manually by doing passwd user1, passwd user2, passwd user3, etcetera. The useradd man page mentions a -p option to define a password, but I can't seem to get this to work.
A common oversight. IIRC, the -p expects tha *encrypted password, as might be found in /etc/shadow. The --stdin others suggest should do it.
<snip>