summaryrefslogtreecommitdiff
path: root/bin/list-ssh-authorized-keys
diff options
context:
space:
mode:
Diffstat (limited to 'bin/list-ssh-authorized-keys')
-rwxr-xr-xbin/list-ssh-authorized-keys24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/list-ssh-authorized-keys b/bin/list-ssh-authorized-keys
new file mode 100755
index 0000000..0722b4f
--- /dev/null
+++ b/bin/list-ssh-authorized-keys
@@ -0,0 +1,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