Class: RHC::Commands::Sshkey
- Includes:
- SSHHelpers
- Defined in:
- lib/rhc/commands/sshkey.rb
Constant Summary
Constants included from Helpers
Helpers::BOUND_WARNING, Helpers::PREFIX, Helpers::ROLES
Instance Method Summary collapse
Methods included from SSHHelpers
#check_ssh_executable!, #exe?, #fingerprint_for_default_key, #fingerprint_for_local_key, #generate_ssh_key_ruby, #has_ssh?, #restore_snapshot, #run_on_gears, #save_snapshot, #ssh_command_for_op, #ssh_key_triple_for, #ssh_key_triple_for_default_key, #ssh_keygen_fallback, #ssh_ruby, #ssh_send_file_ruby, #ssh_send_url_ruby, #ssh_version, #table_from_gears
Methods inherited from Base
Methods included from RHC::ContextHelpers
#find_app, #find_domain, #find_membership_container, #find_team, #from_local_git, included, #namespace_context, #server_context
Methods included from GitHelpers
#git_clone_application, #git_clone_deploy_hooks, #git_clone_repo, #git_cmd, #git_config_get, #git_config_set, #git_remote_add, #git_version, #has_git?
Methods included from Helpers
#agree, #certificate_file, #client_from_options, #collect_env_vars, #color, #confirm_action, #date, #datetime_rfc3339, #debug, #debug?, #debug_error, #decode_json, #deprecated, #deprecated_command, #disable_deprecated?, #distance_of_time_in_words, #env_var_regex_pattern, #error, #exec, #host_exists?, #hosts_file_contains?, #human_size, #info, #interactive?, #jruby?, #mac?, #openshift_online_server?, #openshift_rest_endpoint, #openshift_server, #openshift_url, #pluralize, #results, #role_name, #run_with_tee, #ssh_string, #ssh_string_parts, #ssl_options, #success, #system_path, #table_heading, #to_host, #to_uri, #token_for_user, #unix?, #user_agent, #warn, #windows?, #with_tolerant_encoding
Methods included from OutputHelpers
#default_display_env_var, #display_app, #display_app_configurations, #display_authorization, #display_cart, #display_cart_storage_info, #display_cart_storage_list, #display_deployment, #display_deployment_list, #display_domain, #display_env_var_list, #display_key, #display_team, #format_cart_gears, #format_cart_header, #format_gear_info, #format_key_header, #format_scaling_info, #format_usage_message
Constructor Details
This class inherits a constructor from RHC::Commands::Base
Instance Method Details
#add(name, key_path = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rhc/commands/sshkey.rb', line 50 def add(name, key_path=nil) if key_path type, content, comment = ssh_key_triple_for(key_path) elsif [:type].present? and [:content].present? type = [:type] content = [:content] else raise ArgumentError, "You must either provide a key file, or the key type and content" end if type == 'krb5-principal' # TODO: validate krb5? else # validate the user input before sending it to the server begin Net::SSH::KeyFactory.load_data_public_key "#{type} #{content}" rescue NotImplementedError, OpenSSL::PKey::PKeyError, Net::SSH::Exception => e debug e.inspect if .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_path}' does not appear to be a recognizable key file (#{e}). You may specify the '--confirm' flag to add the key anyway.") if key_path raise ::RHC::KeyDataInvalidException.new("The provided type and content does not appear to be a recognizable key (#{e}). You may specify the '--confirm' flag to add the key anyway.") end end end rest_client.add_key(name, content, type) results { say key_path ? "SSH key #{key_path} has been added as '#{name}'" : "SSH key '#{name}' has been added" } 0 end |
#list ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rhc/commands/sshkey.rb', line 25 def list keys = rest_client.sshkeys.each{ |key| paragraph{ display_key(key) } } success "You have #{keys.length} SSH keys associated with your account." 0 end |
#remove(name) ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/rhc/commands/sshkey.rb', line 88 def remove(name) say "Removing the key '#{name} ... " rest_client.delete_key(name) success "removed" 0 end |
#show(name) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rhc/commands/sshkey.rb', line 36 def show(name) key = rest_client.find_key(name) display_key(key) 0 end |