title: Change Password every week for root user script
body: <p>I got request to change root Password for every 10 days in all Linux based machines and these are production machines and Enabled with grub password so in case we forgot/missed password both root/grub password we cannot recover.</p>
  
  <p>I have wrote a simple script which redirect password to file that is nfs shared file. So it writes password to nfs shared file for every week.</p>
  
  <p>Below is the file format</p>
  
  <pre><code> Machine1:
   Machine2:
   Machine3:
  </code></pre>
  
  <p>we will execute script like </p>
  
  <pre><code> sh autopass.sh Machine1 
  </code></pre>
  
  <p>so it change root Password for the Machine1 and replace Machine1 old Password with new Password in nfs share file. So we will send password to authorized users every week</p>
  
  <p>Below is  script</p>
  
  <pre><code>#!/bin/sh 
  #Function to create Random Password
  function randpass() {
  [ "$2" == "13" ] &amp;&amp; CHAR="[:alnum:]" || CHAR="[:graph:]"
  cat /dev/urandom | tr -cd "$CHAR" | head -c 8
  echo
  }
  #Get Random Password to rootnewpass variable
  rootnewpass=`randpass`
  #Replace new password in file rootpass
  sed -i "s/^\(${1}:\).*/\1${rootnewpass}/" /nfs/rootpass
  #Change new Password using new random generated keyword 
  echo -e "root:$rootnewpass" | chpasswd
  </code></pre>
  
  <p>So Now I wanted here is my approach is good or any other way  is better to implement this. Here concern is at any chance i should not misplace the password meaning should not redirect wrong password to file.</p>
  
  <p>Same concept I am using for grub password as well.</p>
  
  <p>Note: All machines should not have same root password and hence i have opted this option.</p>
  
  <p>Please advice   </p>