Change of password

Hi,

How can I reset the password for the root on every month that needs to send an email after the password change Via shell script.

i don't get your issue.
You want that your root passwd will be changed every month and a mail will be sent?

Yes, I need the password for the server to be changed on the basis of every month and that should be emailed.... Is this can be done Via Shell script.? Can you help me..

You can use the /bin/mail -s "subject" "email" < bodyFile(~/body.txt)

U can use the scheduler to send a email every month, see in you terminal typing contrab --help. This will execute a action,like you script, when you want. To execute this action for all users, or a unique user that u choice, you can overwrite the file "/etc/crontab", adding you action in every month.

Example:
file /etc/crontab
# MINUTS HOUR DAYSOFMONTH MONTH DAYOFWEEK COMMAND
* * 1 * * ./xxx.sh

I hope help you,
Diogo

Hi,

Thank you for your response... I am aware of adding entries in the crontab. but my question is not that, can I have this to be done via a shell script.

I think that its possible.
I made some days ago a script to check if crontab contains my script and add him if it don't contains. When you script is in crontab u can use what i told you to send email. I was searching on google how to change password and i found a script that i guess will help you.
There is the example:
"
for USER in $(cat /tmp/users.txt) do
$(useradd $USER)
###Remove the space between 8 and )
PASSWORD=$(openssl rand -base64 8 )
###passwd [double dash] stdin
echo $PASSWORD | $(passwd �stdin $USER)
echo �$USER $PASSWORD� | mail -s �Your Account Info� $USER@company.com
sleep 3
done
"
You just don't need to read in the file like this script is doing, because u already know the user.

In the website that i found this script, the guy that made it explain a little more about it.

i haven't tested this script, because i am not in my home. Later i will try to do this in my home and come with a response if it do not work for you.

Another thing, about the password. I think you can use some variable like the month and make a calc with it to store on the computer. XOR is a good thing to make it, because you can have later you password encrypted, like a symmetric encrypt.

PS: the website that the script was found: Tip: Add User and Generate Password Script | PinoyTux Weblog
PS2: If this is not exactly what you want, sorry. My english is not so good but i am trying to help with what i understand about the problem. If u need something diferent, try to explain again.
PS3: I am not a expert in shell script, i am just a curious and helping with what i already know. If somebody know a better solution, post a better way to make me learn too.

I hope help you,
Diogo