Find the answer to your Linux question:
Results 1 to 6 of 6
Hey guys, Im trying to figure a script in bash or perl to change the passwords on 100+ machines on a network. All machines use ssh keys. Im thinking probably ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2012
    Location
    North Eastern Coast, U.S.
    Posts
    2

    Need to create a script to change passwords on 100+ machines


    Hey guys,

    Im trying to figure a script in bash or perl to change the passwords on 100+ machines on a network. All machines use ssh keys. Im thinking probably something like this in a for loop. Thanks in advance!

    echo -e "new_password\nnew_password" | (passwd --stdin $USER)

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,696
    This is when you install an OpenLDAP or NIS server, and reconfigure your systems to use one of those for implementing single-sign-on in your network. The amount of work will be about the same as changing all the passwords on all those machines, and your future will be much easier!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    913
    Well, if the password is intended to be the same across all machines, you could simply edit the /etc/shadow file (provided you have su/root access keys) by replacing the old password hash with the new one.

    Here's an example (I don't know if it's a safe or working example, but should show you what you need to do either way)
    Need to reset password on remote host - The UNIX and Linux Forums
    Last edited by mizzle; 08-02-2012 at 02:48 AM. Reason: changed 'passwd' to 'shadow'

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jun 2012
    Location
    North Eastern Coast, U.S.
    Posts
    2
    All hosts are running on solaris and use ssh keys and I want to be able to do it from a list I and possibly put it in a for loop. Setting up LDAP is not an option unfortunately.

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,696
    Quote Originally Posted by RaV3N View Post
    All hosts are running on solaris and use ssh keys and I want to be able to do it from a list I and possibly put it in a for loop. Setting up LDAP is not an option unfortunately.
    If you are running on Solaris, then use YP (Yellow Pages), the original SunOS/Solaris directory tool. That gives you single sign-on across all the systems and you don't have to deal with this cruft.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #6
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    204
    I don't have access to Solaris systems anymore, but as long as they have "usermod" installed you can use the "-p" flag to change the password by supplying the encrypted password instead of the plain text. It's hardly a highly secure, but it might be better to have an encrypted passwords in a script then plain text. The tradeoff is that someone running "ps" or looking though the /proc filesystem some other way can see the encrypted password if they catch it running.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •