summaryrefslogtreecommitdiff
path: root/bin/list-ssh-authorized-keys
blob: 0722b4fd1508c7a557ec0590f82d697f1ce2c971 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env ruby
# Usage: list-ssh-authorized-keys [username]
cfg_hackers="hackers.yml"
cfg_groups = [ "hackers", "bots" ]

######################################################################

require 'yaml'

users = YAML::load(open(cfg_hackers))

if ARGV[0]
	users = users.find_all{|u|u["username"] == ARGV[0]}
else
	users = users.find_all{|u|u["groups"] and not (u["groups"] & cfg_groups).empty?}
end

users.each do |user|
	if user["ssh_keys"]
		user["ssh_keys"].each do |addr,key|
			puts "#{key} #{user["fullname"]} (#{user["username"]}) <#{addr}>"
		end
	end
end