sshfs-offline
sshfs-offline is a Linux or macOS network filesystem.
sshfs-offline is a network filesystem that gives your computer direct access to your files on a remote server. sshfs-offline allows you to use files on your remote server as if they were files on your local computer. text sshfs-offline performs an on-demand download of files when your computer attempts to use them.
Key features
sshfs-offline has several nice features:
-
Only download files when you use them. The deafult is to only download a file if you (or a program on your computer) uses that file.
-
Bidirectional sync. sshfs-offline will only download a file when you access a file that has been changed remotely. If you somehow simultaneously modify a file both locally on your computer and also remotely on your server, sshfs-offline will keep the most recently modified file. The default is to check your remote server once every minute for any remotely changed files.
-
Can be used offline. Files you've opened previously will be available even if your computer has no access to the internet. While your computer is disconnected from the internet, you can continue to update the local filesystem and when you reconnect to the internet, the locally updated files will be uploaded to your server.
-
Fast. sshfs-offline asynchronously performs network requests to your server once every 10 seconds. sshfs-offline caches both filesystem metadata and file contents both in memory and on-disk. Filesytem operations will always be fast unless a large file must be read from Google Drive.
-
gitignore files. Files that match a
.gitignorefile are only cached locally and are not uploaded to your server. This means that Python virtual environment packages in.venvand nodejs packages innode_modulesare only installed locally.
Local Only directories. Directories can be configued to only store files locally in your native filesystem to improve small file performance. The ~/.sshfs-offline/<host>/config.toml file is used to configure local only directories. Thenode_modules directory is configured as a local only directory so node packages are stored locally in your native filesystem, and npm install will run very fast.
This is the default `config.toml' file:
### This is the configuration file.
### It should be placed in $HOME/.sshfs-offline/<host>/config.toml
# Directory names that are only created localy and not synced to Google Drive.
# Files in local only directories are stored in the native filessystem for fast
# updates. Install directories are good candidates to be stored locally.
local_only = [
"node_modules",
]
Quick start
Install FUSE
OSX
On Mac OSX, sshfs-offline requires osxfuse and pkg-config:
$ brew update; brew install pkg-config; brew tap homebrew/cask; brew install --cask osxfuse
Ubuntu / Debian
On Ubuntu / Debian, sshfs-offline requires libfuse-dev, libssl-dev and pkg-config:
sudo apt-get install -y fuse3 libfuse-dev libssl-dev pkg-config
Fedora
On Fedora, sshfs-offline requires gcc, fuse3-devel, and pkg-config:
sudo dnf install -y gcc fuse3-devel pkg-config
Authentication
SSH keys or password authentication are supported.
Install sshfs-offline:
MacOS
Install pipx:
brew install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install sshfs-offline
Ubuntu / Debian
sudo apt update
sudo apt install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install sshfs-offline
Fedora
sudo dnf install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install sshfs-offline
Mount Filesystem
Create mountpoint directory:
MOUNTPOINT=~/mnt
mkdir $MOUNTPOINT
Mount Filesystem:
sshfs-offline mount $MOUNTPOINT --host <your hostname> # add --downloadall to sync all files
Notes:
- It's recommended to run it as user, not as root. For this to work the mountpoint must be owned by the user.
- The cache update interval defaults to 1 minutes, and can be set with the --updateinterval option.
Unmount Filesystem
sshfs-offline unmount $MOUNTPOINT --host <your hostname>
or
fusermount -u $MOUNTPOINT
Display sshfs-offline activity:
sshfs-offline status --host <your hostname>
Building sshfs-offline yourself
Create Virtual Environment:
cd sshfs-offline
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
Mount filesystem:
$ ./src/sshfs_offline/cli.py $MOUNTPOINT
Running tests
The best way to test is to clone a repo, and install, build and run the application.
Mount Filesystem:
sshfs-offline mount $MOUNTPOINT
Setup to debug sshfs-offline
cd $MOUNTPOINT
git clone https://github.com/davechri/sshfs-offline.git
python3 -m venv .venv
b
pip install -r requirements.txt
pip install -e .
Mount local Downloads directory and use diff to verify
./src/sshfs_offline/cli.py mount ~/mnt --host localhost --remotedir ~/Downloads
diff -r ~/Downloads ~/mnt # the DownLoads directory and mnt directory should be identical
Troubleshooting
If the filesystem appears to hang, its possible the fileystem has crashed. To resolve this:
- Remount:
fusermount -u $MOUNTPOINTand remountsshfs-offline mount $MOUNTPOINT --host <your hostname> - Clear the local cache:
fusermount -u $MOUNTPOINTand remountsshfs-offline mount $MOUNTPOINT --clearcache --host <your hostname> - Restart your computer
Logging
- Error Log: error logs are logged to
~/.sshfs-offline/error.log
Debug Logging
For debug logging use the --debug option. The --verbose option will produce more verbose logging.
sshfs-offline mount $MOUNTPOINT --host <your hostname> --debug &> ~/path_to_my_log_file
Display sshfs-offline status
Filesystem statistics are displayed every 10 seconds.
sshfs-offline status --host <hostname>
08:28:45 ONLINE:
LOCAL_ONLY: /home/dave/.sshfs-offline/home/localonly=1.0 GB
REMOTE_FILES: dirs=526 files=934 links=17 cached=13.1 MB fileBytes=1.1 GB
08:28:57 ONLINE:
LOCAL_ONLY: /home/dave/.sshfs-offline/home/localonly=1.0 GB
REMOTE_FILES: dirs=526 files=934 links=17 cached=13.1 MB fileBytes=1.1 GB
08:29:09 ONLINE:
REMOTE CALLS: readdir=1
LOCAL_ONLY: /home/dave/.sshfs-offline/home/localonly=1.0 GB
REMOTE_FILES: dirs=564 files=941 links=20 cached=13.1 MB fileBytes=1.1 GB
Dump Internal State
Display metadata:
sshfs-offline metadata --host <your hostname>
Display directory entries:
sshfs-offline directories --host <your hostname>
Diaplay all unread files:
sshfs-offline unread --host <your hostname>
Display the event queue:
sshfs-offline eventqueue --host <your hostname>
Metadata
Release files for sshfs-offline 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sshfs_offline-1.0.0.tar.gz | 46.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sshfs_offline-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 106.5 kB
Release files / sshfs_offline-1.0.0.tar.gz
| Download URL | sshfs_offline-1.0.0.tar.gz |
|---|---|
| Size | 46.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9da4722adebaef4ccff546ec97544e92a5eb5994e89ea6d7a579b3c77cc8f16e
|
|
BLAKE2b-256 checksum How to use checksums |
27782495f8ed01732b6a185d1ac36169cf37fd4b099491ab5171547fc931ca7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / sshfs_offline-1.0.0-py3-none-any.whl
| Download URL | sshfs_offline-1.0.0-py3-none-any.whl |
|---|---|
| Size | 60.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b206b2cbe05ec5fedf5e677e9b1a2fe891e46f999b5e3bd22a10f954382d2c5f
|
|
BLAKE2b-256 checksum How to use checksums |
acba06cb5cd277e3daa12c94ba18931d7b9a4aa7bd56e2d3b5440f057a977225
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|