Created
          March 29, 2023 04:04 
        
      - 
      
- 
        Save vietanhdev/9a64f9bbb7e24b8f114dda8bd6bc35c4 to your computer and use it in GitHub Desktop. 
    Create ubuntu users with python
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import os | |
| users = """ | |
| john | |
| dummy | |
| vietanhdev | |
| """ | |
| for user in users.split("\n"): | |
| user = user.strip() | |
| if user: | |
| print("User: " + user) | |
| os.system("useradd -m -p $(openssl passwd -1 \"" + (user + "_202303") + "\") -d /home/" + user + " " + user) | |
| os.system(f"chown -R {user}:{user} /home/{user}") | |
| os.system(f"usermod -aG docker {user}") | |
| os.system(f"usermod -aG sudo {user}") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment