Skip to main content

scp client, for use with paramiko.

Project description

A library that implements the client side of the scp (Secure Copy) protocol. It is designed to be used with paramiko (http://www.lag.net/paramiko/).

Using paramiko

There are many ways to use paramiko. For the purposes of these examples, you want to obtain an authenticated SSHClient object:

import paramiko

ssh_client = paramiko.SSHClient()
ssh_client.connect(hostname, username=username, key_filename=key_filename, password=password)

Writing files

The scpclient.Write object is used to write files to an scp server. Its required parameters are a paramiko.SSHClient instance and a remote directory name. It has 2 methods: send_file and send. send_file takes a filename to send, send takes a file-like object, a remote filename, a mode, and a length. You may call send and send_file multiple times.

Example:

with closing(Write(ssh_client.get_transport(), '.')) as scp:
    scp.send_file('file.txt', True)
    scp.send_file('../../test.log', remote_filename='baz.log')

    s = StringIO('this is a test')
    scp.send(s, 'test', '0601', len(s.getvalue()))

Writing directories

Example:

with closing(WriteDir(ssh_client.get_transport(), 'subdir')) as scp:
    scp.send_dir('../../manuals', preserve_times=True, progress=progress)

Reading files

Example:

with closing(ReadDir(ssh_client.get_transport(), '.')) as scp:
    scp.receive_dir('foo', preserve_times=True)

Reading directories

Example:

with closing(Read(ssh_client.get_transport(), '.')) as scp:
    scp.receive('file.txt')

Change log

0.6 2016-10-02 Eric V. Smith

  • Fixed issue #8, Support building wheels.

  • No code changes.

0.5 2014-04-27 Eric V. Smith

  • Fixed issue #5, Not all files included in sdist.

  • Fixed issue #6, Rename bdist RPM to python-scpclient.

  • No code changes.

0.4 2012-11-28 Eric V. Smith

  • Fixed issue #2, Missing contextlib import. Thanks Olivier CARRERE.

0.3 2011-10-31 Eric V. Smith

  • Improved documentation, including how to create a paramiko connection.

0.2 2011-10-31 Eric V. Smith

  • Removed useless tests.

  • Fixed embarassing last minute typo which broke the code.

  • Included trivial examples in README.txt. Needs much work.

  • Forbid files that contain ‘..’ in the filename. This is an attempt to prevent path traversal. This approach is simplistic, but it’s a reasonable first step and gets the job done.

0.1 2011-10-31 Eric V. Smith

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scpclient-0.6.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

scpclient-0.6-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file scpclient-0.6.tar.gz.

File metadata

  • Download URL: scpclient-0.6.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for scpclient-0.6.tar.gz
Algorithm Hash digest
SHA256 56a1e39f1a12a77acef9510ae7d39364be2ca9de7a344236718f459f10cb2dd9
MD5 f899a4c41f829576e3f45c9fb45e84cf
BLAKE2b-256 fac0f3cbc45356da4acd1ed13448c78a5ac95f17d26c8e7bf82011de6fb540a3

See more details on using hashes here.

File details

Details for the file scpclient-0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for scpclient-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dcd36d915f93b50e6b310c2a7f78af705d665c1d624b75a6bf0884dbd0b0376b
MD5 3984ff772f6c069aa6a664414332d0c9
BLAKE2b-256 e4c9467c3ef43b08eefd412f6ea6f1dadb42ce21fdc4dceba1da85ee8c9a3190

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page