-
-
Save anonymous/cdca193097477d9be9a9 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
require 'io/console' | |
def do_create_user(no,us,pw) | |
pwd = pw.crypt("$5$a1") | |
1.upto(no) do | x | | |
uname = us + x.to_s | |
result = system("useradd -m -p '#{ pwd }' #{ uname }") | |
if result | |
puts "#{ uname } created!" | |
else | |
puts "#{ uname } failed!" | |
end | |
end | |
end | |
print "How many users do you want? " | |
count = gets.chomp.to_i | |
print "Enter the username suffix, user, u etc... " | |
user = gets.chomp.downcase | |
print "Enter Password: " | |
password = STDIN.noecho(&:gets).chomp | |
puts "" # print an empty line | |
do_create_user(count,user,password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment