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

######################################################################
require 'yaml'

users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))}

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