summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Blaine <jblaine@kickflop.net>2015-08-31 15:29:35 -0400
committerBryan McLellan <btm@chef.io>2015-11-23 18:05:01 -0500
commit925317bfd39a6b395a7117e01dd1dea78e240f40 (patch)
treecf3bfaa3da1c500b80556a4c445862a934c8d01d
parent3419637a9d287782162b3fd76041a449bc5f07e7 (diff)
downloadchef-925317bfd39a6b395a7117e01dd1dea78e240f40.tar.gz
DTRT re: identity_file
-rw-r--r--lib/chef/knife/bootstrap.rb4
-rw-r--r--lib/chef/knife/ssh.rb22
2 files changed, 12 insertions, 14 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 5d9c2a46ba..30ea3cac6c 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -430,8 +430,7 @@ class Chef
ssh.config[:ssh_port] = config[:ssh_port]
ssh.config[:ssh_gateway] = config[:ssh_gateway]
ssh.config[:forward_agent] = config[:forward_agent]
- ssh.config[:identity_file] = config[:identity_file] # DEPRECATED
- ssh.config[:ssh_identity_file] = config[:ssh_identity_file]
+ ssh.config[:ssh_identity_file] = config[:ssh_identity_file] || config[:identity_file]
ssh.config[:manual] = true
ssh.config[:host_key_verify] = config[:host_key_verify]
ssh.config[:on_error] = :raise
@@ -440,7 +439,6 @@ class Chef
def knife_ssh_with_password_auth
ssh = knife_ssh
- ssh.config[:identity_file] = nil
ssh.config[:ssh_identity_file] = nil
ssh.config[:ssh_password] = ssh.get_password
ssh
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index eeed7827f4..fcffb718f5 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -232,8 +232,8 @@ class Chef
{}.tap do |opts|
# Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user]
opts[:user] = user || config[:ssh_user] || ssh_config[:user]
- if config[:identity_file]
- opts[:keys] = File.expand_path(config[:identity_file])
+ if config[:ssh_identity_file]
+ opts[:keys] = File.expand_path(config[:ssh_identity_file])
opts[:keys_only] = true
elsif config[:ssh_password]
opts[:password] = config[:ssh_password]
@@ -396,7 +396,7 @@ class Chef
window = 0
session.servers_for.each do |server|
tf.print("screen -t \"#{server.host}\" #{window} ssh ")
- tf.print("-i #{config[:identity_file]} ") if config[:identity_file]
+ tf.print("-i #{config[:ssh_identity_file]} ") if config[:ssh_identity_file]
server.user ? tf.puts("#{server.user}@#{server.host}") : tf.puts(server.host)
window += 1
end
@@ -406,7 +406,7 @@ class Chef
def tmux
ssh_dest = lambda do |server|
- identity = "-i #{config[:identity_file]} " if config[:identity_file]
+ identity = "-i #{config[:ssh_identity_file]} " if config[:ssh_identity_file]
prefix = server.user ? "#{server.user}@" : ""
"'ssh #{identity}#{prefix}#{server.host}'"
end
@@ -473,9 +473,9 @@ class Chef
end
raise Chef::Exceptions::Exec, "no command found for cssh" unless cssh_cmd
- # pass in the consolidated itentity file option to cssh(X)
- if config[:identity_file]
- cssh_cmd << " --ssh_args '-i #{File.expand_path(config[:identity_file])}'"
+ # pass in the consolidated identity file option to cssh(X)
+ if config[:ssh_identity_file]
+ cssh_cmd << " --ssh_args '-i #{File.expand_path(config[:ssh_identity_file])}'"
end
session.servers_for.each do |server|
@@ -520,9 +520,9 @@ class Chef
end
end
- def configure_identity_file
- config[:identity_file] = get_stripped_unfrozen_value(config[:identity_file] ||
- Chef::Config[:knife][:ssh_identity_file])
+ def configure_ssh_identity_file
+ # config[:identity_file] is DEPRECATED in favor of :ssh_identity_file
+ config[:ssh_identity_file] = get_stripped_unfrozen_value(config[:ssh_identity_file] || config[:identity_file] || Chef::Config[:knife][:ssh_identity_file])
end
def extract_nested_value(data_structure, path_spec)
@@ -536,7 +536,7 @@ class Chef
configure_user
configure_password
- configure_identity_file
+ configure_ssh_identity_file
configure_gateway
configure_session