Sample Header Ad - 728x90

Password Aging: Script

0 votes
0 answers
100 views
We have to implement Password Aging in our environment. I know that it is very much possible using chage and shadow file. But since our Passwords are handeled by NIS, we can not use chage method in order to implement password ageing. I just wonder if I can write a script which checks the passwd file periodically(daily) in order to findout who all users have NOT changed their passwords since lets say 180 Days and I get a mail notification. So that I can inform the users and ask them to change their passwords. Some sort of Password ageing. I know it will not be a perfect case but we have to go with this workaround. We only have 55 UNIX Users so far. Since I am not into programming, I would request you all to provide me some hints as to how to do it. I have given a try but is not worth it. ###Here the script will change the difference in two password files passwd.2 and passwd.11 and if there are differences then record them(only Usernames) in the file Table #!/bin/bash #set -x if [[ "$(diff passwd.2 passwd.11 )" != "" ]]; then ( date ; echo FileChanged ) >> Status2 ( diff passwd.2 passwd.11 ) >> Status2 diff --unchanged-line-format="" --old-line-format="" --new-line-format=":%dn: %L" passwd.2 passwd.11 |awk -F: '{print $3}' >> Table tail -15 Status2 tail -15 Table else ( date ; echo NOFileChanged ) >> Status2 fi A sample password file is given below. passwd: t1:$2y$05$lFZBPdAihnWxJPwfHeoI8WBdhzZGtcVJXXXXXXXXXXXXXXXXX:10954:20000:Test User temporary:/home/t1:/bin/bash fdl:Nologin*:499:20190:fdl,Application User:/home/fdl:/bin/csh v1:$2y$05$lPdAihnWXXXXXXXXXXXXXXXXXcPwfHeoI8WBdhzZGtcVJXXXXXXXXXXXXXXXXX:10955:20000:Test User temporary:/home/v1:/bin/bash v2:$2y$05BPdAihnWxJeXXXXXXXXXXXXXXXXXoI8WBdhzZGXXXXXXXXXXXXXXXXX:10956:20000:Test User temporary:/home/v2:/bin/bash v3:$2y$05$lFZBPdAiXXXXXXXXXXXXXXXXXoI8WBdhzZGXXXXXXXXXXXXXXXXX:10957:20000:Test User temporary:/home/v3:/bin/bash v4:$2y$05$lFZBPdAXXXXXXXXXXXXXXXXXfHeoI8WBdhzXXXXXXXXXXXXXXXXX:10958:20000:Test User temporary:/home/v4:/bin/bash
Asked by Sachin H (171 rep)
May 6, 2022, 06:41 PM