Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created February 1, 2016 01:12
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 anonymous/cdca193097477d9be9a9 to your computer and use it in GitHub Desktop.
Save anonymous/cdca193097477d9be9a9 to your computer and use it in GitHub Desktop.
#!/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