def add(name, key)
type, content, comment = ssh_key_triple_for(key)
begin
Net::SSH::KeyFactory.load_data_public_key "#{type} #{content}"
rescue NotImplementedError, OpenSSL::PKey::PKeyError, Net::SSH::Exception => e
debug e.inspect
if options.confirm
warn 'The key you are uploading is not recognized. You may not be able to authenticate to your application through Git or SSH.'
else
raise ::RHC::KeyDataInvalidException.new("File '#{key}' does not appear to be a recognizable key file (#{e}). You may specify the '--confirm' flag to add the key anyway.")
end
end
rest_client.add_key(name, content, type)
results { say "SSH key #{key} has been added as '#{name}'" }
0
end