summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornikhil2611 <nikhilgupta2102@gmail.com>2023-03-15 19:01:10 +0530
committernikhil2611 <nikhilgupta2102@gmail.com>2023-03-15 19:01:10 +0530
commit73c0ace3615d3c0e06bb9952a165b8d7e65abab7 (patch)
tree26220acf8b32c2d5f4cc8d5be4ed2d0c0c94d0e1
parent54e9be16e0e2e6a65471133a3f7c28c1d9d8688f (diff)
downloadchef-73c0ace3615d3c0e06bb9952a165b8d7e65abab7.tar.gz
managed the file and RequestTTY exist
Signed-off-by: nikhil2611 <nikhilgupta2102@gmail.com>
-rw-r--r--knife/lib/chef/knife/bootstrap.rb16
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?