Simple Username/Password based SFTP Client.
sftpclient
is a simple to use sftp client to connect to remote FTP servers over ssh (SFTP) using username/password combo.
Uploads and downloads work with file-handles by default so as to not fill up the working directory with downloaded files when the desire was just to read and parse the data available at the remote server.
Default downloads are in bytes
mode mode=rb
, use an io.TextIOWrapper
to read the file as text.
Sample usage
from sftpclient import SFTPClient
client = SFTPClient(
host=SFTPHOST,
username=YOURSFTPUSERNAME,
password=YOURSFTPPASSWORD,
use_known_hosts=UPTOYOUTODECIDE,
)
with open('somefile') as file_to_upload:
client.upload(file_to_upload, destination='/uploads')
file = client.download('/data/consume.txt', text=True)
for line in file: