lib/rye/box.rb in rye-0.9.1 vs lib/rye/box.rb in rye-0.9.2
- old
+ new
@@ -258,36 +258,40 @@
# rbox = Rye::Box.new 'somemachine'
# rbox.bash
#
# TODO: refactor to use net_ssh_exec! in 0.9
def interactive_ssh(run=true)
- debug "interactive_ssh with keys: #{Rye.keys.inspect}"
- run = false unless STDIN.tty?
- cmd = Rye.prepare_command("ssh", "#{@rye_user}@#{@rye_host}")
+ debug "interactive_ssh with keys: #{@rye_opts[:keys].inspect}"
+ run = false unless STDIN.tty?
+ args = []
+ @rye_opts[:keys].each { |key| args.push *[:i, key] }
+ args << "#{@rye_user}@#{@rye_host}"
+ cmd = Rye.prepare_command("ssh", args)
return cmd unless run
system(cmd)
end
- # Add one or more private keys to the SSH Agent.
- # * +additional_keys+ is a list of file paths to private keys
+ # Add one or more private keys to the list of key paths.
+ # * +keys+ is a list of file paths to private keys
# Returns the instance of Box
- def add_keys(*additional_keys)
- if Rye.sysinfo.os == :windows
- @rye_opts[:keys] ||= []
- @rye_opts[:keys] += additional_keys.flatten
- return @rye_opts[:keys]
- end
- additional_keys = [additional_keys].flatten.compact || []
- return if additional_keys.empty?
- #ret = Rye.add_keys(additional_keys)
- #if ret.is_a?(Rye::Rap)
- # debug "ssh-add exit_status: #{ret.exit_status}"
- # debug "ssh-add stdout: #{ret.stdout}"
- # debug "ssh-add stderr: #{ret.stderr}"
- #end
+ def add_keys(*keys)
+ @rye_opts[:keys] ||= []
+ @rye_opts[:keys] += keys.flatten.compact
+ @rye_opts[:keys].uniq!
self # MUST RETURN self
end
alias :add_key :add_keys
+
+ # Remove one or more private keys fromt he list of key paths.
+ # * +keys+ is a list of file paths to private keys
+ # Returns the instance of Box
+ def remove_keys(*keys)
+ @rye_opts[:keys] ||= []
+ @rye_opts[:keys] -= keys.flatten.compact
+ @rye_opts[:keys].uniq!
+ self # MUST RETURN self
+ end
+ alias :remove_key :remove_keys
# Return the value of uname in lowercase
# This is a temporary fix. We can use SysInfo for this, upload
# it, execute it directly, parse the output.
def ostype