Guest User

Untitled

a guest
Sep 6th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. def new_user(admin_username, admin_password):
  2. env.user = 'root'
  3.  
  4. # Create the admin group and add it to the sudoers file
  5. admin_group = 'admin'
  6. runcmd('addgroup {group}'.format(group=admin_group))
  7. runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format(
  8. group=admin_group))
  9.  
  10. # Create the new admin user (default group=username); add to admin group
  11. runcmd('adduser {username} --disabled-password --gecos ""'.format(
  12. username=admin_username))
  13. runcmd('adduser {username} {group}'.format(
  14. username=admin_username,
  15. group=admin_group))
  16.  
  17. # Set the password for the new admin user
  18. runcmd('echo "{username}:{password}" | chpasswd'.format(
  19. username=admin_username,
  20. password=admin_password))
Add Comment
Please, Sign In to add comment