Skip to content

Instantly share code, notes, and snippets.

@grenade
Last active December 22, 2015 15:48
Show Gist options
  • Save grenade/6494591 to your computer and use it in GitHub Desktop.
Save grenade/6494591 to your computer and use it in GitHub Desktop.
# Requires fabric: sudo yum -y install fabric gcc python-devel python-setuptools
from fabric.api import env, task, hide, sudo
user1 = 'foo'
pass1 = 'bar'
user2 = 'baz'
pass2 = 'qux'
passwords = {
'host1': [
{'username': user1, 'password': pass1},
{'username': user2, 'password': pass2}
],
'host2': [
{'username': user1, 'password': pass1},
{'username': user2, 'password': pass2}
]
}
env.hosts = passwords.keys()
@task(default=True)
def change_remote_passwords():
with hide('running'):
for user in passwords[env.host]:
sudo(command='echo %s| passwd %s --stdin' % (user['password'],user['username']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment