# File lib/rhc-common.rb, line 1098
def add_or_update_key(command, identifier, pub_key_file_path, rhlogin, password)

  # Read user public ssh key
  if pub_key_file_path
    if File.readable?(pub_key_file_path)
      begin
        ssh_keyfile_contents = File.open(pub_key_file_path).gets.chomp.split(' ')
        ssh_key = ssh_keyfile_contents[1]
        ssh_key_type = ssh_keyfile_contents[0]
      rescue Exception => e
        puts "Invalid public keyfile format! Please specify a valid user public keyfile."
        exit 1
      end
    else
      puts "Unable to read user public keyfile #{pub_key_file_path}"
      exit 1
    end
  else # create key
    key_name = identifier
    puts "Generating ssh key pair for user '#{key_name}' in the dir '#{Dir.pwd}/'"
    # REMOVED in favor of generate_ssh_key_ruby: system("ssh-keygen -t rsa -f '#{key_name}'")
    ssh_pub_key_file = generate_ssh_key_ruby()
    ssh_keyfile_contents = File.open(ssh_pub_key_file).gets.chomp.split(' ')
    ssh_key = ssh_keyfile_contents[1]
    ssh_key_type = ssh_keyfile_contents[0]
  end

  data = {}
  data[:rhlogin] = rhlogin
  data[:key_name] = identifier
  data[:ssh] = ssh_key
  data[:action] = 'add-key'
  data[:key_type] = ssh_key_type

  if command == 'add'
    data[:action] = 'add-key'
  elsif command == 'update'
    data[:action] = 'update-key'
  end

  url = URI.parse("https://#{RHC::Config['libra_server']}/broker/ssh_keys")
  handle_key_mgmt_response(url, data, password)
end