连接

https://docs.paramiko.org/en/stable/api/sftp.html

transport = paramiko.Transport(('192.168.110.51', 22))
try:
    #transport.connect(username='root', password='123456') 
    ftp = paramiko.SFTPClient.from_transport(transport)
except Exception as e:
    print(e)
    print('远程连接失败...')

#下载中
ftp.get(from_file, to_file)

ftp.chdir(to_dir)
ftp.chdir('..')
ftp.mkdir(item)

检测目录是否存在

try:
    sftp.stat(path)
    print("exist")
except IOError:
    print("not exist")

# 获取远程的子目录列表
lst = self.ftp.listdir(self.X['remote_dir'])