I'm using paramiko to execute commands on another server and most of the time it works fine but for some servers it hangs after executing few commands.
I'd like to know how to troubleshoot and understand the issue.
this is the code I have.
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_ley_policy(paramiko.AutoAddPolicy)
ssh = client.connect('hostname,username,password')
channel = ssh.invoke_shell()
stdin = channel.makefile('wb')
stdout = channel.makefile('r')
stdin.write(cmd+'\n')
stdin.flush()
#it hangs here
for line in stdout:
print(line)