pysftp

Parallel downloads with Multiprocessing and PySftp

依然范特西╮ 提交于 2020-02-24 11:17:07
问题 I'm trying to create a code to download N files at the same type using pysftp and multiprocessing libs. I made a basic python training, got pieces of codes and combined them into one, but I can't get it work out. I'd appreciate if somebody helps me with that. The error occurs after the vFtp.close() command. In the part that suppose to start simultaneous downloads. from multiprocessing import Pool import pysftp import os vHost='10.11.12.13' vLogin='admin' vPwd='pass1234' vFtpPath='/export/home

pysftp vs. Paramiko

梦想与她 提交于 2020-02-20 07:23:29
问题 I have a simple requirement to drop a file on an SFTP server. I have found pysftp and Paramiko libraries that seem to allow me to this and developed a simple application using Paramiko but I can't find a proper source that compares the two so I can decide which one I can/should use. What are the pros and cons for each? 回答1: pysftp is a wrapper around Paramiko with a more Python-ish interface. pysftp interface does not expose all of the features of Paramiko. On the other hand, pysftp

PySFTP failing with “No hostkey for host X found” when deploying Django/Heroku

若如初见. 提交于 2020-01-23 17:27:32
问题 I'm trying to deploy a Django web application which uses pysftp to access to a SFTP server through some views. The thing was perfectly working in local development, but when trying the first deployment on Heroku, the traceback below appeared ending with an error. It seems like I need to configure host keys and I believe I also need to set them in known_hosts at Heroku, but I have no idea about how to do that. In local development I was accessing with user/password without a problem, but from

Why is Python Complaining About libcrypto When Importing pysftp on macOS Catalina v10.15.1?

谁说胖子不能爱 提交于 2020-01-14 05:15:06
问题 I just upgraded my MacBook to Catalina v10.15.1. When executing my python script which only does one thing, imports pysftp, I get the following output: WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error. Could somebody shed some light on why this is occurring? Thank you. 来源: https://stackoverflow.com/questions/58777860/why-is-python

Python pysftp.put raises “No such file” exception although file is uploaded

馋奶兔 提交于 2020-01-14 04:29:06
问题 I am using pysftp to connect to a server and upload a file to it. cnopts = pysftp.CnOpts() cnopts.hostkeys = None self.sftp = pysftp.Connection(host=self.serverConnectionAuth['host'], port=self.serverConnectionAuth['port'], username=self.serverConnectionAuth['username'], password=self.serverConnectionAuth['password'], cnopts=cnopts) self.sftp.put(localpath=self.filepath+filename, remotepath=filename) Sometimes it does okay with no error, but sometime it puts the file correctly, BUT raises the

Python Connect over HTTP proxy with pysftp

≯℡__Kan透↙ 提交于 2020-01-13 13:00:50
问题 Currently, I am doing SFTP transfer using Python subprocess.POPEN and PuTTY psftp.exe . It is working, but not really clean nor transportable. I would like to reproduce the same behavior using Python pysftp, but I do not know where to input all the parameters. I have in PuTTY the following configuration: Server IP : 123.123.123.255 Server Port : 22 Connection Type : SSH AutoLogin UserName : MyUser Proxy type : HTTP Proxy Hostname : gw.proxy.fr Proxy port : 1234 Proxy Username : ProxyUser

PySFTP/Paramiko exceptions leaking into stderr

旧时模样 提交于 2020-01-13 06:50:08
问题 I am trying to catch paramiko exceptions but they are still written to stderr. Is there a way to stop writing there? EDIT: It happens even before paramiko gets involved: import pysftp try: pysftp.Connection(host="localhost") except Exception as e: print(e) Results in: Example with proper SFTP params: UPDATE: $ pipenv graph ... pysftp==0.2.9 - paramiko [required: >=1.17, installed: 2.6.0] ... $ pipenv run python Python 3.7.3 (default, Jul 19 2019, 11:21:39) [Clang 11.0.0 (clang-1100.0.28.3)]

Python pysft/paramiko 'EOF during negotiation' error

陌路散爱 提交于 2019-12-24 01:43:31
问题 I'm using pysftp to download and upload some files. This exact same code I just run an hour before and was fine, but now I got this 'EOF during negotiation' error. What am I missing here? >>> sftp = pysftp.Connection(host, username=user, password=pasw) >>> sftp <pysftp.Connection object at 0x7f88b25bb410> >>> sftp.cd('data') <contextlib.GeneratorContextManager object at 0x7f88b1a86910> >>> sftp.exists(filename) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr

Specify file pattern in pysftp get

眉间皱痕 提交于 2019-12-21 03:55:09
问题 We can write a simple get like this: import pysftp hostname = "somehost" user = "bob" password = "123456" filename = 'somefile.txt' with pysftp.Connection(hostname, username=user, private_key='/home/private_key_file') as sftp: sftp.get(filename) However, I want to specify a pattern in the filename, something like: '*.txt' Any idea on how to do this using pysftp ? 回答1: There's no function to download files matching a file mask in pysftp. You have to: list the directory, using listdir or

Use Paramiko AutoAddPolicy with pysftp

自闭症网瘾萝莉.ら 提交于 2019-12-18 04:21:51
问题 This code is not working: def sftp_connection(self): import pysftp connection = pysftp.Connection(self.host, username=self.system_name, private_key=os.path.join(HOME, '.ssh', 'id_rsa')) # in the next lines I try to use AutoAddPolicy client = connection.sftp_client() client.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy) return connection This is the exception: Traceback (most recent call last): File "/home/u/src/myapp