Skip to content

Instantly share code, notes, and snippets.

@haritak
Created September 20, 2017 12:49
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 haritak/38c1711c1c636dcd51cfac14426ae253 to your computer and use it in GitHub Desktop.
Save haritak/38c1711c1c636dcd51cfac14426ae253 to your computer and use it in GitHub Desktop.
This script will read a csv file and reset the passwords. It assumes first value to be the username and the last one to be the password.
#!/usr/bin/ruby
File.open("2017-2018-usernames-passwords.csv").each do |line|
line = line.split ","
username = line[0]
password = line[-1]
puts "#{username} #{password}"
end
puts "Hit enter to reset all above passwords."
gets
File.open("2017-2018-usernames-passwords.csv").each do |line|
line = line.split ","
username = line[0].strip.gsub("$", "\\$")
password = line[-1].strip.gsub("$", "\\$")
puts "echo '#{username}:#{password}' | chpasswd"
`echo "#{username}:#{password}" | chpasswd`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment