sftp server implementaion with Python

你离开我真会死。 提交于 2019-12-12 06:57:00

问题


I need to implement sftp server using python. My requirement is to move the file from remote machine to my application using the sftp commands like

copy configurations sftp://<ipaddress>/<filename>

Is it possible to do with Paramiko. If so any code snippet or doc on how to accomplish it would be helpful.


回答1:


The following code snippet demonstrates simple implementation of sftp client with paramiko

>>> import paramiko
>>> pkey = paramiko.RSAKey.from_private_key_file('rsa.key')
>>> transport = paramiko.Transport(('localhost', 3373))
>>> transport.connect(username='username', password='password', pkey=pkey)
>>> sftp = paramiko.SFTPClient.from_transport(transport)
>>> sftp.listdir('.')
['File.txt', 'File2.txt']

Very simple SFTP server in python: sftpserver 0.2



来源:https://stackoverflow.com/questions/17290974/sftp-server-implementaion-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!