This article attempts to provide a script for changing a linux user's password across multiple hosts.
The following script could be used as a Rightscript in the dashboard. Be sure to fill in inputs where necessary for HOSTS and PASSWORD:
#!/bin/bash for host in $HOSTS; do ssh root@$host "usermod -p $PASSWORD $USERNAME"; done
This simple one liner will take multiple values for $HOSTS (space separated), then SSH into each (as the root user) and issue the usermod command to change $USERNAME's password to a value of $PASSWORD.
This may be useful in some scenarios, and it can be made a bit more powerful if needed. For example:
#!/bin/bash for host in $HOSTS; do ssh root@$host "usermod -p `perl -e 'print crypt("change-me", "salt")'` $USERNAME"; done
This will iterate through all hosts and generate a random password using the crypt function. Simply change 'change-me' to a value of your choosing and ensure inputs are filled in as needed.
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.