Skip to content
← Back to activity

Public problem

Knife SSH error using sudo when targeting multiple hosts

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Running knife ssh against multiple hosts with a sudo command (e.g. knife ssh 'chef_environment:blah' 'sudo uptime') failed with an ArgumentError, while the same command without sudo worked fine. The bug was in the ssh session handling when a pseudo-terminal was needed for sudo across multiple sessions. The failure only appeared with sudo because that is what forced the pty allocation across the sessions.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Fixed upstream in PR #11431, which is packaged into knife 17.3.48 and newer (and backported into still-supported chef 16.x lines like 16.16.13). Verify the knife gem version on your workstation and upgrade so knife is at 17.3.48 or newer. As a temporary workaround, adding the --require-pty flag to the knife ssh command raises an error if a pty cannot be requested, which surfaces the real problem instead of the ArgumentError. Source: https://github.com/chef/chef/issues/10763

Source: https://github.com/chef/chef/issues/10763