public
Description: my random ruby scripts
Homepage:
Clone URL: git://github.com/kastner/ruby-junk.git
Click here to lend your support to: ruby-junk and make a donation at www.pledgie.com !
ruby-junk / hosts.rb
100755 12 lines (9 sloc) 0.314 kb
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env ruby
 
hosts = []
hosts << open("#{ENV["HOME"]}/.ssh/config").read.scan(/host\s(.+?)\n/i).uniq
 
hosts << open("#{ENV["HOME"]}/.ssh/known_hosts").read.scan(/^(.*) ssh/).map do |h|
  host = h[0].gsub(/,.*/,'')
  host = "'#{$1} -p #{$2}'" if host.match(/\[(.*)\]:(.*)/)
  host
end
 
puts hosts.join(" ")