diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index be7624c05d..a3e9e04ccb 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -162,7 +162,7 @@ class Connection(ConnectionBase): return p = connection_loader.get('paramiko', self._play_context, '/dev/null') - p.set_options(direct={'look_for_keys': bool(self._play_context.password and not self._play_context.private_key_file)}) + p.set_options(direct={'look_for_keys': not bool(self._play_context.password and not self._play_context.private_key_file)}) p.force_persistence = self.force_persistence ssh = p._connect() @@ -261,6 +261,10 @@ class Connection(ConnectionBase): while True: data = self._ssh_shell.recv(256) + # when a channel stream is closed, received data will be empty + if not data: + break + recv.write(data) offset = recv.tell() - 256 if recv.tell() > 256 else 0 recv.seek(offset)