summaryrefslogtreecommitdiff
path: root/bin/list-ssh-authorized-keys
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2014-09-05 01:31:14 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2014-09-05 01:31:14 -0400
commit4b70501e432eb5fd9ed04a4afbadafabd982e9fc (patch)
treeb09fe80d9ec0ec3eb82f46dbfce960dc66aaf3f4 /bin/list-ssh-authorized-keys
parent1ab58422fb47e22e178716efa3fbce5beabbc174 (diff)
restructure to have most data in YAML
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