Guest User

sshmod.py

a guest
Jan 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import fabric
  3. from fabric.api import env, sudo, local, settings
  4. import config
  5.  
  6. env.user = 'root'
  7. env.host_string = '94.177.252.78'
  8. env.password = config.senha_sudo
  9.  
  10. def useradd(nome, senha):
  11.     env.password = config.senha_sudo
  12.     resultado = sudo("useradd -M -s /bin/false {0}".format(nome), quiet=True)
  13.     if not resultado.failed:
  14.         sudo("(echo {0} ; echo {0} ) | passwd {1}".format(senha, nome), quiet=True)
  15.         return True
  16.     else:
  17.         return False
Add Comment
Please, Sign In to add comment