Skip to main content

Pyfilesystem2 over SSH using paramiko

Project description

miarec_sshfs SFTP filesystem for PyFilesystem2

Actions License

This is a fork of fs.sshfs project, with modifications that are required for our needs.

Requirements

PyFilesystem2 PyPI fs Source fs License fs
six PyPI six Source six License six
paramiko PyPI paramiko Source paramiko License paramiko
property-cached PyPI property Source property License property

miarec_sshfs supports Python versions 3.6+

Notable differences to fs.sshfs

  1. Loading of configuration from SSH Config files (~/.ssh/config) is removed due to potential security issues, when this component used in SaaS project.

  2. Automatic loading of SSH keys from SSH Agent is forbidden due to potential security issues, when this components is used in SaaS project.

  3. The opener protocol prefixes are mssh:// and msftp:// (instead of the original ssh:// and sftp://)

  4. URL is forbidden due to potential leak of SFTP credentials via url.

Installation

Install from GitHub, using pip:

$ pip install git+https://github.com/miarec/miarec_sshfs@master

Usage

To connect to an SSH server, use the fs.sshfs.SSHFS constructor, which signature is:

from miarec_sshfs import SSHFS
my_fs = SSHFS(
  host, user=None, passwd=None, pkey=None, timeout=10, port=22,
  keepalive=10, compress=False, config_path='~/.ssh/config'
)

with each argument explained below:

  • host: the name or IP address of the SSH server
  • user: the username to connect with, defaults to the current user.
  • passwd: an optional password, used to connect directly to the server or to decrypt the public key, if any given.
  • pkey: a paramiko.PKey object, a path, or a list of paths to an SSH key.
  • timeout: the timeout, in seconds, for networking operations.
  • port: the port the SSH server is listening on.
  • keepalive: the interval of time between keepalive packets, in seconds. Set to 0 to disable.
  • compress: set to True to compress the communications with the server.
  • config_path: the path to an OpenSSH configuration file.
  • exec_timeout: the timeout, in seconds, for arbitrary SSH commands on the server.
  • policy: a paramiko.MissingHostKeyPolicy instance, or None to use paramiko.AutoAddPolicy.

Additional keyword arguments will be passed to the underlying paramiko.SSHClient.connect call, taking precedence over implicitly derived arguments. Once created, the SSHFS filesystem behaves like any other filesystem (see the PyFilesystem2 documentation).

Files

SSHFS.openbin has the following extra options that can be passed as keyword arguments to control the file buffering:

  • prefetch: enabled by default, use a background thread to prefetch the content of a file opened in reading mode. Does nothing for files in writing mode.
  • pipelined: enable pipelined mode, avoid waiting for server answer between two uploaded chunks. Does nothing for files in reading mode.

Testing

Automated unit tests are run on GitHub Actions

To run the tests locally, do the following.

Install Docker on local machine.

Create activate python virtual environment:

python -m vevn venv
source venv\bin\activate

Install the project and test dependencies:

pip install -e ".[test]"

Run tests:

pytest -v

Feedback

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproductible situation.

Credits

miarec_ssfs is developed and maintained by MiaRec

Original code (fs.sshfs) was developed by:

The following people contributed to fs.sshfs:

This project obviously owes a lot to the PyFilesystem2 project and all its contributors.

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

miarec_sshfs-2024.1.3.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

miarec_sshfs-2024.1.3-py2.py3-none-any.whl (24.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file miarec_sshfs-2024.1.3.tar.gz.

File metadata

  • Download URL: miarec_sshfs-2024.1.3.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for miarec_sshfs-2024.1.3.tar.gz
Algorithm Hash digest
SHA256 1658ca1ac2992ad7f468083b205fdc82b7e0b3dccbc8ed8240fdf373b25ef764
MD5 ba4f1dadd8dafd04368b39108a1502f0
BLAKE2b-256 efdc50921a6623a36e0368d9c9007a5d6c7ced3674864f8578a3cea06c659fea

See more details on using hashes here.

File details

Details for the file miarec_sshfs-2024.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for miarec_sshfs-2024.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80be5ad9cdee4ec9bd27b8062d45f749cdbc14230b37adad41d5a62422a68636
MD5 1c7c136f362dcfde8f6d7219784d64ab
BLAKE2b-256 d9326315fdb29168138e1087a37ec994a78f7a8260720e4c2178627148f18c17

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