Created
September 9, 2017 05:11
-
-
Save pinfort/74424f148e9a519382216edd20fe2a19 to your computer and use it in GitHub Desktop.
メールユーザー追加用スクリプト python2
This file contains 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
# -*- 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