summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/knife/ssh.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index 6a8e10267d..41d002cbd6 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -134,6 +134,12 @@ class Chef
boolean: true,
default: false
+ option :ssh_pty,
+ long: "--ssh-pty",
+ description: "PTY flag. Provide this option if PTY is configured on node.",
+ boolean: true,
+ default: false
+
def session
ssh_error_handler = Proc.new do |server|
if config[:on_error]
@@ -366,7 +372,11 @@ class Chef
if config[:on_error] && exit_status != 0
chan.close
else
- chan.request_pty
+ if config[:ssh_pty]
+ chan.request_pty do |ch, success|
+ raise Train::Transports::SSHPTYFailed, "Requesting PTY failed" unless success
+ end
+ end
chan.exec command do |ch, success|
raise ArgumentError, "Cannot execute #{command}" unless success