I have a code where i am executing a command on remote Linux machine and reading the output using Paramiko. The code def looks like this:
ssh = paramiko.SSHC
It's easier if you use the high level representation of an open ssh session. Since you already use ssh-client to open your channel, you can just run your command from there, and avoid the extra work.
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(IPAddress, username=user['username'], password=user['password'])
stdin, stdout, stderr = ssh.exec_command(cmd)
for line in stdout.readlines():
print line
for line in stderr.readlines():
print line
You will need to come back and read from these files handles again if you receive additional data afterwards.