Sha256: 8bbedc79d05129785d9cae69a5789822d347b7dd23f422b24fbd3d85d953d071

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module CapSshKeyMan
  class PublicKeyCombiner
    AUTHORIZED_KEYS_PATH = File.join ".", "tmp", "authorized_keys"
    PUBLIC_KEY_PATH      = File.join(".", "config", "developer_public_keys")
    OMNI_RSA_KEY_PATH    = File.expand_path(File.join "~", ".ssh", "id_rsa.pub")
    OMNI_DSA_KEY_PATH    = File.expand_path(File.join "~", ".ssh", "id_dsa.pub")

    def self.combine_developer_public_keys_to public_key_path = PUBLIC_KEY_PATH
      File.open AUTHORIZED_KEYS_PATH, "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, '*')]
        raise "Can't find any public keys in #{public_key_path} dir." if files.size == 0
        files.each do |file|
          f.write File.read(file)
        end
      end
    end

    def self.get_current_user_public_key_path
      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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cap-ssh-key-man-1.2.3 lib/cap-ssh-key-man/public_key_combiner.rb