Knife SSH error using sudo when targeting multiple hosts

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.

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