diff options
-rw-r--r-- | knife/lib/chef/knife/bootstrap.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/knife/lib/chef/knife/bootstrap.rb b/knife/lib/chef/knife/bootstrap.rb index eea11b3b6f..ffbe8dcdb6 100644 --- a/knife/lib/chef/knife/bootstrap.rb +++ b/knife/lib/chef/knife/bootstrap.rb @@ -950,13 +950,25 @@ class Chef opts = {} return opts if winrm? - ssh_config_file = File.open(File.join(Dir.home, ".ssh/config")).read - ssh_config_file.include?("RequestTTY yes") ? opts[:non_interactive] = false : opts[:non_interactive] = true # Prevent password prompts from underlying net/ssh + ssh_config_tty ? opts[:non_interactive] = false : opts[:non_interactive] = true # Prevent password prompts from underlying net/ssh opts[:forward_agent] = (config[:ssh_forward_agent] === true) opts[:connection_timeout] = session_timeout opts end + #checks the ~/.ssh/config file to check RequestTTY is set to yes + def ssh_config_tty + if File.exists?(File.join(Dir.home, ".ssh/config")) + ssh_config_file = File.open(File.join(Dir.home, ".ssh/config")).read + if ssh_config_file.include?("RequestTTY") + tty_key_index = ssh_config_file.index("RequestTTY") + tty_value = ssh_config_file[tty_key_index...].split[1].downcase + return true if tty_value == "yes" + end + end + return false + end + def ssh_identity_opts opts = {} return opts if winrm? |