Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cron job, init.d and ppp start, where and when ?
Message
Information générale
Forum:
Linux
Catégorie:
Problèmes base de données, installation et Admin
Divers
Thread ID:
00442396
Message ID:
00447686
Vues:
14
>>Is it possible to create a script which, when run, would read the user table...
>
>Well, this answer is going to be different depending on which password database you want to replicate. For instance, if you want to replicate the system passwd/group file, it will be different than if you want to replicate MySQL permissions.
>
>> ...and generate a second script which, if run on a new installation, would create those accounts on that installation?
>>I see the essence of if using 'useradd' but I'm not sure which files contain that info. Passwords are encrypted in passwd so I'd have to have run it through a decryption algorithm (?)... ?????
>
>You don't need to use useradd if you already have a password/group file. You are most likely using shadow passwords and groups. The tools you need are:
>
>pwconv, pwunconv, grpconv, grpunconv
>
>These tools are used to encrypt and decrypt shadow passwords. So you can read a password file, decrypt it, remove the system entries (root, bin, daemon... etc), and then boom. You can transfer and recrypt. You could even write the script generator to embed the password file so that everything is self contained.
>You could store everything encrypted if you preserve the original passwd, shadow, group, and gshadow, but if someone has those, they can decrypt it with pwunconv and grpunconv, so it's up to you how you do it.
>
>j

Wow. In reading over my own message I wondered which idiot was let out of the asylum to wonder around UT....
Basically, what I wanted to do was create a recovery script which would allow me to add about 100 users to a new install (if a replacement of a currently running box was ever necessary).

I've found a useradd script on the internet that solves my problem.
What I've had to do is make a copy of /etc/shadow and use it as the source for info to create a set of new accounts.
**************************************************************
#!/bin/bash
# pass input file to STDIN of the while read line ; do loop
cat /path/inputfile |
while read line ; do

# clear the variables (not needed, but good coding practice)
username=""
password=""

# set the variables
username=`echo $line | cut -d":" -f1`
password=`echo $line | cut -d":" -f2`

# check variables
if [ "$username" != "" -a "$password" != "" ] ; then
useradd $username
# set the password for the new user automagically
echo $username:$password | chpasswd
else
# oops, no username and/or password - maybe blank line in file?
echo "$username:$password" >> /tmp/importerror.log
fi
done
********************************************************
JLK
Nebraska Dept of Revenue
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform