使用Paramiko从远程主机获取文件的Python代码

使用Paramiko从远程主机获取文件的Python代码,python,linux,python-2.7,ssh,paramiko,Python,Linux,Python 2.7,Ssh,Paramiko,这是一台linux主机,我想列出其中的文件/文件夹。但是,我得到的是空列表[] 请任何人建议我如何继续列出该文件中的内容 import paramiko paramiko.util.log_to_file(r'D:\logs\paramico.log') ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('xxx.xxx.xx.xx', port=22,

这是一台linux主机,我想列出其中的文件/文件夹。但是,我得到的是空列表[]

请任何人建议我如何继续列出该文件中的内容

import paramiko
paramiko.util.log_to_file(r'D:\logs\paramico.log')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('xxx.xxx.xx.xx', port=22, username='xxxxx', password='xxxxxx')
stdin, stdout, stderr = ssh.exec_command('ll')
output = stdout.readlines()
print '\n'.join(output)
print output

由于我的主机有隐藏文件,我需要使用ls-al

代码看起来很好。还可以打印stderr.readlines()吗。在使用stderr.readlines()之后,我得到了输出bash:ll:command not found。但在CLI中,我可以看到输出ubuntu@ubuntu:~$ll总计28 drwxr-xr-X3 ubuntu 4096 Mar 27 11:08./drwxr-xr-X3根目录4096 Mar 27 11:03../-rw------1 ubuntu 120Mar 27 11:09.bash_history-rw-r--r--1 ubuntu 220 Mar 27 11:03.bash_注销-rw-r--r--1 ubuntu 3637 Mar 27 11:03.bashrc drwx--2 ubuntu4096年3月27日11:05.cache/-rw-r--r--1 ubuntu 675年3月27日11:03.profile
import paramiko
paramiko.util.log_to_file(r'D:\logs\paramico.log')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('xxx.xxx.xx.xx', port=22, username='xxxxx', password='xxxxxx')
stdin, stdout, stderr = ssh.exec_command('ls -al')
output = stdout.readlines()
output1 = stderr.readlines()
print '\n'.join(output)
print output
print output1