Multi Password Change

How to start with Linux, learning Linux

Here is a handy script to change your password on multiple servers at once. This can be very useful when you are working in a Linux server environment with multiple hosts.

Here is the script

#!/bin/bash
for server in `cat ~/servers`; do
echo $server;
ssh user@$server 'passwd << EOF
old password
new password
verify new password
EOF';
done

As you can see, you need a file with all the hosts (~/servers), on which you want to change your password. Put every host on a new line.

Don’t forget to change:
– user
– old password
– new password
– verify new password
to your actual passwords, you want to use. You don’t have to put quotes around them.

Run this script in the same directory as the servers file, or change the path in the script