bin/rye in rye-0.4.1 vs bin/rye in rye-0.4.3

- old
+ new

@@ -19,66 +19,37 @@ include Drydock global :p, :path, String, "A directory containing SSH private keys or the path to a private key" before do |obj| - STDERR.puts # Load private keys if specified if obj.global.path keys = Rye.find_private_keys(obj.global.path) Rye.add_keys(keys) end end after do - STDERR.puts + end desc "Add your public keys to one or more remote machines" option :u, :user, String, "Username" argv :hostname command :authorize do |obj| raise "You must specify a host" unless obj.argv.hostname - highline = HighLine.new # Used for password prompt - opts = { :debug => nil, :auth_methods => %w(publickey hostbased) } opts[:user] = obj.option.user if obj.option.user obj.argv.each do |hostname| - - retried = 0 - begin - rbox = Rye::Box.new(hostname, opts).connect - puts "Authorizing #{rbox.opts[:user]}@#{hostname}" if retried == 0 - - # We know we're already authorized b/c we didn't have to give a password - if retried == 0 - puts "%s is already authorized" % rbox.opts[:user] - puts - next - end - - # An authentication failure means either the requested user doesn't - # exist on the remote machine or we need to supply a password. - rescue Net::SSH::AuthenticationFailed => ex - STDERR.puts - retried += 1 - if retried <= 3 - #opts[:password] = highline.ask("Password: ") { |q| q.echo = '' } - opts[:auth_methods] = %w(password keyboard-interactive) - retry - else - STDERR.puts "Authentication failed." - exit 1 - end - end - + rbox = Rye::Box.new(hostname, opts).connect + puts "Authorizing #{rbox.opts[:user]}@#{hostname}" puts "Added public keys for: ", rbox.authorize_keys + puts "Now try: " << "ssh #{rbox.opts[:user]}@#{hostname}" - puts end end command_alias :authorize, :authorise @@ -122,10 +93,10 @@ default :keys debug :off -# We can Drydock specifically otherwise it will run at_exit. Rye also +# We call Drydock specifically otherwise it will run at_exit. Rye also # uses at_exit for shutting down the ssh-agent. Ruby executes at_exit # blocks in reverse order so if Drydock is required first, it's block # will run after Rye shuts down the ssh-agent. begin Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?