I am using the the python paramiko library to SSH into a FTP server. I am able to use the command line to access the server and retrieve a list of files using the sftp command, however paramiko seems to be doing something that prevents me from retrieving output. Here is my python code:
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('###########',
port=##,
username='####',
password='####',
key_filename='#####')
stdin, stdout, stderr = client.exec_command('ls')
this all works just fine. However the next line
stdout.readline()
just sits there and hangs. Notice that per this thread I am not even trying to retrieve the full output, just the first line.
I also tried
stdin.close()
print(stdout.readlines())
which returns an empty string. This suggests that maybe the server is waiting for input, but when I use the command line I am able to just send the ls command and get the output so what command could it be waiting for?
Versions:
- python 3.7.4
- paramiko 2.7.1