Im writing a python code to login to a linux server and to do a FTP connection. I use module paramiko. I face a problem where the recv does not read entire contents of the buffer irrespective of the size of the buffer that I use. Am I missing anything here?
import paramiko
from paramiko import SSHClient
host = '10.x.x.x'
port = 22
username = 'root'
password = 'docker'
ssh = SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)
chan = ssh.invoke_shell()
try:
data = chan.recv(1024)
print(data)
except Exception as e:
print(e)
Manual login output is:
Last login: Thu Dec 16 02:00:14 2021 from xxxxxx
[root@localhost ~]#
But on script i see only this line stored in buffer.
Last login: Thu Dec 16 02:00:14 2021 from xxxxxx
ACtually I want to terminate my readming till I encounter '#' or end of buffer but unable to do it. could you kindly help.