Skip to content

Instantly share code, notes, and snippets.

@vietanhdev
Created March 29, 2023 04:04
Show Gist options
  • Save vietanhdev/9a64f9bbb7e24b8f114dda8bd6bc35c4 to your computer and use it in GitHub Desktop.
Save vietanhdev/9a64f9bbb7e24b8f114dda8bd6bc35c4 to your computer and use it in GitHub Desktop.
Create ubuntu users with python
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