- Fix authentication failure with paramiko when using password mode (#33303)

- break out of loop when paramiko stream is closed
This commit is contained in:
Kedar K 2017-11-27 18:47:17 +05:30 committed by Ricardo Carrillo Cruz
parent 0e0470bc49
commit e65ef09aa9

View file

@ -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)