Skip to main content

SSH File System with offline access to cached files.

Project description

sshfs-offline

SSH File System with offline access to cached files.

Features:

  • Based on FUSE (Filesystem in Userspace framework for Linux)

  • Metadata and Data are cached locally to improve performance.

  • Offline access to cached data when the remote host is not reachable

  • Read/Write file system

Install Script:

$ pip install sshfs-offline

How to mount a filesystem

Usage:

```sh
usage: sshfs-offline [-h] [-p PORT] [-u USER] [-d REMOTEDIR] [--debug] [--cachetimeout CACHETIMEOUT] host mountpoint

To unmount use: fusermount -u mountpoint

positional arguments:
  host                  remote host name
  mountpoint            local mount point (eg, ~/mnt)

options:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  port number (default=22)
  -u USER, --user USER  user on remote host
  -d REMOTEDIR, --remotedir REMOTEDIR
                        directory on remote host (eg, ~/)
  --debug               run in debug mode
  --cachetimeout CACHETIMEOUT
                        duration in seconds to keep metadata cached (default is 5 minutes)

```

Example:

```sh
sshfs-offline localhost ~/mnt
```

Note, that it's recommended to run it as user, not as root. For this to work the mountpoint must be owned by the user. If the username is different on the host you are connecting to, then use the --user option.

If you need to enter a password sshfs-offline will ask for it. You can also specify a remote directory using --remotedir. The default is your home directory.

The cache timeout defaults to 5 minutes, and can be set with the -cachetimeout option.

To unmount the filesystem:

fusermount -u mountpoint

Cache Implementation

The data and metadata are cached in the .sshfs-offline directory. In this example, the test/myfile.txt file has two 132K blocks. The data is cached in the data sub-directory, and the metadata is cached in the metadata sub-directory.

  .sshfs-offline
├── data
│   └── localhost   # host name       └── home
│           └── dave
│               └── test                   └── myfile.txt 
└── metadata
    └── localhost   # host name
        └── home
            └── user                
                ├── %test        # test direcotry
                   ├── getattr  # lstat status for directory
                   └── readdir  # directory entries
                └── %test%myfile.txt  # test/myfile.txt file
                    ├── blockmap      # track blocks that are cached
                    └── getattr       # lstat status for file 

Debugging

  • Metrics are logged to the ~/.sshfs-offline/metrics.log file.
  • In production (--debug=False), the log level is set to warning, and logs are writtend to the ~/.sshfs-offline/error.log file.
  • If the --debug option is specified, the log level is set to debug, the process is run in the foreground, and logs are written to stdout.

Using the tail command to follow the metrics:

$ tail -f ~/.sshfs-offline
2025-09-23 07:26:19,237:INFO:metrics 
   getattr         : 181
   getattr_hit     : 181
   init            : 1
   readdir         : 26
   readdir_hit     : 26
   readlink        : 104
   readlink_hit    : 104
   sftp_chdir      : 1
   sftp_connected  : 1
   sftp_healthThread: 1
   sftp_start      : 1

Development

Create Virtual Environment:

$ python3 -m venv my-venv-name
$ source ~/my-venv-name/bin/activate
$ pip install -r requirements.txt

Mount filesystem:

$ ./src/sshfs_offline/cli.py localhost ~/mnt

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

sshfs_offline-0.0.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sshfs_offline-0.0.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file sshfs_offline-0.0.2.tar.gz.

File metadata

  • Download URL: sshfs_offline-0.0.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sshfs_offline-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e36f5b9948353cf1e780c6d69e7a10e7ac26f7f39bea97958dc4162d8bb02f92
MD5 d8d6b1f30f055694c20baa37930256ed
BLAKE2b-256 1dc4273f3ac7d59e78718448d337082e6ebc1b0cfbfced78258164480ac83656

See more details on using hashes here.

File details

Details for the file sshfs_offline-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: sshfs_offline-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sshfs_offline-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 42187ea80af1738c5ff70e362d666d3c687fc409091d95ac961247fd9f86b1d0
MD5 08cfa89e7a8b0637e30eb439e928dd14
BLAKE2b-256 ae565ca7f403e66912a76410de3c0d1d34fd431150c454995f79cb40976884df

See more details on using hashes here.

Supported by

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