From a443fe5d51ff27235b0a6d7c92d92b0c2715aee8 Mon Sep 17 00:00:00 2001 From: Marc Seeger Date: Tue, 10 Jul 2012 13:30:30 +0200 Subject: [PATCH] Fix ssh key behavior when passing specified private keys to ssh/scp --- lib/fog/core/scp.rb | 8 ++++++++ lib/fog/core/ssh.rb | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/fog/core/scp.rb b/lib/fog/core/scp.rb index 80a8deebc..76231463a 100644 --- a/lib/fog/core/scp.rb +++ b/lib/fog/core/scp.rb @@ -52,6 +52,14 @@ module Fog raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH') end + if options[:key_data] || options[:keys] + options[:keys_only] = true + #Explicitly set these so net-ssh doesn't add the default keys + #as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146 + options[:keys] = [] unless options[:keys] + options[:key_data] = [] unless options[:key_data] + end + @address = address @username = username @options = { :paranoid => false }.merge(options) diff --git a/lib/fog/core/ssh.rb b/lib/fog/core/ssh.rb index 00e91b037..fdb869a1a 100644 --- a/lib/fog/core/ssh.rb +++ b/lib/fog/core/ssh.rb @@ -46,6 +46,14 @@ module Fog raise ArgumentError.new(':key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH') end + if options[:key_data] || options[:keys] + options[:keys_only] = true + #Explicitly set these so net-ssh doesn't add the default keys + #as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146 + options[:keys] = [] unless options[:keys] + options[:key_data] = [] unless options[:key_data] + end + @address = address @username = username @options = { :paranoid => false }.merge(options)