Skip to content

Instantly share code, notes, and snippets.

@pinfort
Created September 9, 2017 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinfort/74424f148e9a519382216edd20fe2a19 to your computer and use it in GitHub Desktop.
Save pinfort/74424f148e9a519382216edd20fe2a19 to your computer and use it in GitHub Desktop.
メールユーザー追加用スクリプト python2
# -*- coding: utf-8 -*-
import os
import random
username = raw_input("user name? >>")
cmd = "useradd -s /sbin/nologin " + username
os.system(cmd)
length = random.randint(8, 12)
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890%/'
newpass = ""
for i in range(1, length):
newpass = newpass + random.choice(chars)
print "youcan use this string to new password."
print newpass
cmd = "passwd " + username
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment