Class: SshKeyMan::PublicKeyCombiner
- Inherits:
-
Object
- Object
- SshKeyMan::PublicKeyCombiner
- Defined in:
- lib/file_combiner.rb
Class Method Summary collapse
Class Method Details
.combine(group) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/file_combiner.rb', line 3 def self.combine group puts "combining public keys ..." = File.join ".", "authorized_keys" public_key_path = File.join(".", "available_public_keys") File.open , "w" do |f| f.write File.read(get_current_user_public_key_path) if get_current_user_public_key_path files = Dir[File.join(public_key_path, group, "*")] raise "No such a server group: #{group}" if files.size == 0 files.each do |file| f.write File.read(file) end end puts "finished combining public keys ..." end |
.get_current_user_public_key_path ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/file_combiner.rb', line 23 def self.get_current_user_public_key_path omni_rsa_key_path = File.(File.join "~", ".ssh", "id_rsa.pub") omni_dsa_key_path = File.(File.join "~", ".ssh", "id_dsa.pub") current_user_key_path = nil current_user_key_path = omni_rsa_key_path if File.exist?(omni_rsa_key_path) current_user_key_path = omni_dsa_key_path if File.exist?(omni_dsa_key_path) current_user_key_path end |