Generate random password for each user
This commit is contained in:
parent
7e7b031cea
commit
5df268645e
1 changed files with 7 additions and 2 deletions
9
adduser
9
adduser
|
@ -10,6 +10,10 @@ lastname = input('Enter last name: ')
|
|||
email = input('Enter email: ')
|
||||
uid = input('Enter UID: ')
|
||||
|
||||
# Password
|
||||
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()
|
||||
hashedpassword = os.popen('slappasswd -s ' + password).read()
|
||||
print('Password:', password)
|
||||
|
||||
# Construct LDIF
|
||||
ldif = '''dn: uid={username},ou=People,dc=exozy,dc=me
|
||||
|
@ -23,7 +27,7 @@ uid: {username}
|
|||
cn: {firstname} {lastname}
|
||||
sn: {lastname}
|
||||
givenName: {firstname}
|
||||
userPassword: {SSHA}bz40SXh6L4eoUwmDDGySG5xLLW8oQPwA
|
||||
userPassword: {hashedpassword}
|
||||
mail: {email}
|
||||
loginShell: /bin/fish
|
||||
uidNumber: {uid}
|
||||
|
@ -38,7 +42,8 @@ gidNumber: {uid}'''.format(username=username,
|
|||
firstname=firstname,
|
||||
lastname=lastname,
|
||||
email=email,
|
||||
uid=uid)
|
||||
uid=uid,
|
||||
hashedpassword=hashedpassword)
|
||||
|
||||
|
||||
# Write to file and get confirmation
|
||||
|
|
Loading…
Reference in a new issue