summaryrefslogtreecommitdiff
path: root/lib/chef/knife/ssh.rb
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2012-11-20 12:15:48 -0800
committerBryan McLellan <btm@opscode.com>2012-11-20 12:27:37 -0800
commit832674e6254b287a9cd188d5a1756955bee45c6c (patch)
treeda7da8354523cfe32f38097a084d3e09ef8f416a /lib/chef/knife/ssh.rb
parent15f94f373d5c21593e2bad35bc81a190176f7af1 (diff)
parent8dc20721f1c4afc3e8434516d1ebf3bc0d9264d9 (diff)
downloadchef-832674e6254b287a9cd188d5a1756955bee45c6c.tar.gz
Merge branch '10-stable'
Conflicts: chef-expander/lib/chef/expander/version.rb chef-server-api/lib/chef-server-api/version.rb chef-server-webui/lib/chef-server-webui/version.rb chef-server/lib/chef-server/version.rb chef-solr/lib/chef/solr/version.rb chef/lib/chef/encrypted_data_bag_item.rb chef/spec/unit/encrypted_data_bag_item_spec.rb ci/jenkins_run_tests.bat ci/jenkins_run_tests.sh lib/chef/provider.rb spec/unit/knife/data_bag_from_file_spec.rb spec/unit/provider/remote_directory_spec.rb spec/unit/provider/route_spec.rb
Diffstat (limited to 'lib/chef/knife/ssh.rb')
-rw-r--r--lib/chef/knife/ssh.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index a1b37723a6..ed3c559d05 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -72,7 +72,6 @@ class Chef
:short => "-p PORT",
:long => "--ssh-port PORT",
:description => "The ssh port",
- :default => "22",
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
option :ssh_gateway,
@@ -166,13 +165,17 @@ class Chef
list.each do |item|
Chef::Log.debug("Adding #{item}")
-
- hostspec = config[:ssh_user] ? "#{config[:ssh_user]}@#{item}" : item
session_opts = {}
+
+ ssh_config = Net::SSH.configuration_for(item)
+
+ # Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user]
+ user = config[:ssh_user] || ssh_config[:user]
+ hostspec = user ? "#{user}@#{item}" : item
session_opts[:keys] = File.expand_path(config[:identity_file]) if config[:identity_file]
session_opts[:keys_only] = true if config[:identity_file]
session_opts[:password] = config[:ssh_password] if config[:ssh_password]
- session_opts[:port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port]
+ session_opts[:port] = config[:ssh_port] || Chef::Config[:knife][:ssh_port] || ssh_config[:port]
session_opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug
if !config[:host_key_verify]