SFTP in Python? (platform independent)
Paramiko supports SFTP. I've used it, and I've used Twisted. Both have their place, but you might find it easier to start with Paramiko.
SFTP in Python? (platform independent)
Paramiko supports SFTP. I've used it, and I've used Twisted. Both have their place, but you might find it easier to start with Paramiko.
Most recent SFTP python package and best practices
For the first error, it seems like a bug in pysftp
.
You can have a look at the Connection
class here on line 76, and the attribute _sftp_live
is defined on line 134, so this is definitely an error occurring at runtime without being validated correctly. I have also been able to find this related error, which likely explains the cause of this issue; the solution is also mentioned in the error if you want to explicitly fix it.
I would still consider using ftpretty
. It does use TLS
for security and a pretty safe wrapper, you can simply enable it by setting the secure parameter to True (secure=True
) - which by default is set as False
.
Use custom command to start SFTP server in pysftp/Paramiko
What that option in WinSCP does is that it runs SFTP over the "exec" channel, instead of the "sftp subsystem" channel. An (untested) equivalent in Python Paramiko:
ssh = paramiko.SSHClient()
# authenticate here
chan = ssh.get_transport().open_session()
chan.exec_command("/path/to/sftp-server")
sftp = paramiko.SFTPClient(chan)
ftplib connects to SFTP server without error
FTP and SFTP are two completely different protocols. They have absolutely nothing in common. There's no chance you can connect with an FTP library to an SFTP server.
Your log shows FTP session without any doubt.
Though you (or your host) may mistake SFTP with FTPS (FTP over TLS/SSL). See FTPS versus SFTP. For FTPS, just use FTP_TLS
class instead of FTP
. The interface is the same (FTP_TLS
derives from FTP
).
If you really need SFTP (over SSH), you need to use a different library, like Paramiko or pysftp.
See SFTP in Python? (platform independent).
Dealing with remote folders while using the os module in a python code?
I'm sorry to disappoint you, but the situation is indeed exactly as you describe in your question:
Yes, you do need to mount your remote directory if you want to use os.walk
, os.remove
, shutil.move
, etc.
If you use a specialized SFTP library such as paramiko
(or calling ssh/sftp via the subprocess
module), you'll have to implement the functionaliy of os.walk
on your own.
By the way, if you decide to implement your own os.walk
on top of paramiko
, you might want to contribute that function back to paramiko
, as it may be helpful for other users of that library, too.
Related Topics
Simple Way to Encode a String According to a Password
How to Change Backends in Matplotlib/Python
Merge Lists That Share Common Elements
Python -Intersection of Multiple Lists
Polling the Keyboard (Detect a Keypress) in Python
Match Text Between Two Strings with Regular Expression
Testing Whether a Numpy Array Contains a Given Row
How to Append a New Row to an Old CSV File in Python
Sftp in Python? (Platform Independent)
Pandas Dataframe Get First Row of Each Group
How to Read First N Lines of a File
How to Remove Stop Words Using Nltk or Python
Is There a Decorator to Simply Cache Function Return Values
How to Access "Static" Class Variables Within Methods in Python
Typeerror: Not All Arguments Converted During String Formatting Python
Python: Ignore 'Incorrect Padding' Error When Base64 Decoding