Created
September 20, 2017 12:49
-
-
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.
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 | |
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