Skip to main content

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.7 2010-10-27 Eric V. Smith

  • Remove hack for changing the RPM name (issue #10).

  • No code changes.

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.

Metadata

Release files for scpclient 0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scpclient 0.7
File Size Uploaded
scpclient-0.7.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scpclient 0.7
File Interpreter ABI Platform
scpclient-0.7-py2-none-any.whl Python 2 none any Details

Total release size: 19.6 kB

Release files / scpclient-0.7.tar.gz

Download URL scpclient-0.7.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2a7336123d9fbfb0064907719747a96f1c0add38a99b4d2741adc218d25e11d6
BLAKE2b-256 checksum
How to use checksums
3772e1a25df7e5562ad4c5f48c0d3ab43045b56d6680f38aff3fa058a95729c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scpclient-0.7-py2-none-any.whl

Download URL scpclient-0.7-py2-none-any.whl
Size 9.0 kB
Tags Python 2
SHA-256 checksum
How to use checksums
bce7a4429d2d8ec1ceae5de99acf5bf3e04b63e27fa832dfac9173d8be98493e
BLAKE2b-256 checksum
How to use checksums
2d5319b5fe3db38c349d877a1ac9af898de0ac2c36f26a1730cd1c1ab2b2001b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.7 This release

2 release files

0.6

2 release files

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page