使用 Python 实现 sftp 服务器 [英] sftp server implementaion with Python

查看:61
本文介绍了使用 Python 实现 sftp 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用python实现sftp服务器.我的要求是使用

等 sftp 命令将文件从远程机器移动到我的应用程序

复制配置sftp:///

是否可以与Paramiko一起做.如果是这样,任何关于如何完成它的代码片段或文档都会有所帮助.

解决方案

以下代码片段演示了使用 paramiko

简单实现 sftp 客户端<预><代码>>>>进口paramiko>>>pkey = paramiko.RSAKey.from_private_key_file('rsa.key')>>>运输 = paramiko.Transport(('localhost', 3373))>>>transport.connect(username='username', password='password', pkey=pkey)>>>sftp = paramiko.SFTPClient.from_transport(transport)>>>sftp.listdir('.')['文件.txt', '文件2.txt']

python 中非常简单的 SFTP 服务器:sftpserver 0.2

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.

解决方案

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

这篇关于使用 Python 实现 sftp 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆