Created
January 9, 2014 15:50
-
-
Save txus/8336323 to your computer and use it in GitHub Desktop.
nifty nice yeah
This file contains hidden or 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/env ruby | |
require 'open-uri' | |
abort("Usage: pgpkey [[email protected]|emails.txt]") unless ARGV.first | |
emails = if File.exist?(ARGV.first) | |
File.readlines(ARGV.first).map(&:chomp) | |
elsif ARGV.first =~ /@/ | |
[ARGV.first] | |
end | |
emails.each do |email| | |
begin | |
lines = open("http://pgp.mit.edu:11371/pks/lookup?search=#{URI.encode(email)}&op=index").readlines | |
p lines | |
id = lines.reject { |line| | |
line =~ /REVOKED/ | |
}.select { |line| | |
line =~ /pks\/lookup/ | |
}.each { |l| | |
p l | |
}.first.scan(/([A-Z0-9]+)<\/a>/).flatten.first | |
puts "Found key #{id} for #{ARGV.first}." | |
`gpg --recv-keys #{id}` | |
rescue | |
puts "Didn't find any key for #{ARGV.first}." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment