How to reset multiple users password on Linux
How to reset multiple users password on Linux?
Choose a new password using perl with crypt format
#perl -e ‘print crypt(“newpassword”, “salt”),”\n”‘
sal.HhR9nxBk6
Reset password for any userID larger than 499 with new default password “newpassword”
#for acc in $(awk -F: ‘{ if ($3 > 499) { print $1 }}’ /etc/passwd); do
usermod -p sal.HhR9nxBk6 $acc;
done
Reset password for any userID larger than 499 but not userID=1150 & 1160 with new default password “newpassword”
#for acc in $(awk -F: ‘{ if ($3 > 499 && $3 !=1150 && $3 !=1160) { print $1 }}’ /etc/passwd); do
usermod -p sal.HhR9nxBk6 $acc;
done
Reset Samba password for any userID larger than 499 with new default password “newpassword”
#for acc in $(awk -F: ‘{ if ($3 > 499) { print $1 }}’ /etc/passwd); do
(echo ‘newpassword’; echo ‘newpassword’)|smbpasswd -s $acc;
done
Reset Samba password for any userID larger than 499 but not userID=1150 & 1160 with new default password “newpassword”
#for acc in $(awk -F: ‘{ if ($3 > 499 && $3 !=1150 && $3 !=1160) { print $1 }}’ /etc/passwd); do
(echo ‘newpassword’; echo ‘newpassword’)|smbpasswd -s $acc;
done
How to change user password expiry information
#for acc in $(awk -F: ‘{ if ($3 > 999) { print $1 }}’ /etc/passwd); do chage -m 7 -M 76 -W 14 -I 14 $acc; done
Quick check on one of the user
#chage -l test
Minimum: 0
Maximum: 76
Warning: 14
Inactive: 14
Last Change: Jul 01, 2008
Password Expires: Sep 15, 2008
Password Inactive: Sep 29, 2008
Account Expires: Never
Minimum = minimum number of days between password changes is changed
Maximum = maximum number of days during which a password is valid is changed
Warning = the number of days of warning before a password change is required can be changed
Inactive = used to set the number of days of inactivity after a password has expired before the account is locked
Read more
Possibly Related Posts:
- How to add Dell PERC Drivers into VMware Converter Cold Clone ISO
- Top 10 Free Anti Virus
- How to Install Webmin on OpenFiler
- Microsoft SQL 2008 Agent not starts
- VMware Workstation 7 Serial Key
How to SYNC Linux and Samba user password
In order to sync Linux user password and Samba user password, you have to configure PAM. Personally I’m using SLES9 for my testing environment and I have to configure /etc/pam.d/passwd and /etc/pam.d/sshd as following:
password required pam_smbpass.so nullok try_first_pass use_authtok
How to test?
Create a new user called testing
#useradd -m testing
Setup default password
#passwd testing
Create a new samba user
#smbpasswd -a testing
#New SMB password:
#Retype new SMB password:
Configure password expire for user testing
#passwd -e testing
Login as user testing and you should be able to enter new password.
How to check whether Linux and Samba password are sync?
Make sure both file having the same date & time
#ls -l /etc/shadow
#ls -l /etc/samba/smbpasswd
Test Linux login
#SSH to my machine with user testing and new password
Read more
Possibly Related Posts:
- How to add Dell PERC Drivers into VMware Converter Cold Clone ISO
- Top 10 Free Anti Virus
- How to Install Webmin on OpenFiler
- Microsoft SQL 2008 Agent not starts
- VMware Workstation 7 Serial Key