Skip to main content

Pyfilesystem2 over SSH using paramiko

Project description

Source PyPI Conda Travis Codecov Codacy Format License


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


Install directly from PyPI, using pip

pip install fs.sshfs



Use fs.open_fs to open a filesystem with an SSH FS URL:

import fs
my_fs = fs.open_fs("ssh://[user[:password]@]host[:port]/[directory]")

The sftp scheme can be used as an alias for the ssh scheme in the FS URL. The following URL parameters are supported: timeout, keepalive.


For a more granular way of connecting to an SSH server, use the fs.sshfs.SSHFS constructor, which signature is:

from fs.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:

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

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


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

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.
enable pipelined mode, avoid waiting for server answer between two uploaded chunks. Does nothing for files in reading mode.


SSHFS are aware of SSH config files and as such, one of the hosts in the configuration file can be provided as the host argument for the filesystem to connect to the server with the proper configuration values.


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.

See also

  • fs, the core pyfilesystem2 library
  • fs.archive, enhanced archive filesystems for pyfilesystem2
  • fs.smbfs, Pyfilesystem2 over SMB using pysmb

Project details

Download files

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

Files for fs.sshfs, version 0.12.3
Filename, size File type Python version Upload date Hashes
Filename, size fs.sshfs-0.12.3-py2.py3-none-any.whl (22.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size fs.sshfs-0.12.3.tar.gz (23.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page