Skip to main content

FUSE filesystem backed by smbclient (smbprotocol)

Project description

smb-pyfuse

Mount SMB/CIFS shares as local directories using FUSE.

Built on top of smbprotocol and fuse-python, smb-pyfuse exposes a remote SMB share as a regular filesystem — supporting reads, writes, directory listing, symlinks, and more.

Features

  • Mount any SMB2/SMB3 share as a local directory
  • Username/password and Kerberos authentication
  • Optional SMB3 encryption
  • Foreground and background (daemon) modes
  • allow_other / allow_root FUSE mount options
  • Programmatic Python API (mount, unmount, SmbFuseFS)

Supported FUSE Operations

Operation Description
getattr File/directory metadata (stat)
readdir List directory contents
mkdir / rmdir Create / remove directories
rename Rename files or directories
unlink Delete a file
mknod Create a new regular file
open / read / write / release File I/O
truncate / ftruncate Truncate a file
flush / fsync Flush / sync file data
symlink / readlink / link Symbolic and hard links
utime Update access/modification times
chmod / chown No-op (silently succeeds for tool compatibility)
access Existence check via stat
statfs Returns sensible defaults

Prerequisites

System Dependencies

sudo apt install libkrb5-dev build-essential python3-dev

FUSE

FUSE must be available on the host:

# Debian / Ubuntu
sudo apt install fuse3 libfuse-dev

# To allow non-root users to use allow_other:
# Uncomment 'user_allow_other' in /etc/fuse.conf

Installation

# Clone the repo
git clone https://github.com/<your-org>/smb-pyfuse.git
cd smb-pyfuse

# Install with uv (recommended)
uv sync --frozen

# Or with pip
pip install .

Usage

CLI

Mount a share (foreground mode):

uv run main.py mount /mnt/smb myserver.example.com myshare -u 'DOMAIN\user' -p 'password' -f

Mount with Kerberos (requires a valid TGT in the credential cache):

kinit user@REALM
uv run main.py mount /mnt/smb myserver.example.com myshare --kerberos -f

Mount in the background (daemon mode):

uv run main.py mount /mnt/smb myserver.example.com myshare -u user -p pass

Unmount:

uv run main.py unmount /mnt/smb

CLI Options

positional arguments:
  mountpoint            Local directory to mount the share at
  server                SMB server hostname or IP address
  share                 Share name (without backslashes)

options:
  -u, --username        SMB username
  -p, --password        SMB password
  --port                SMB TCP port (default: 445)
  --kerberos            Authenticate with Kerberos TGT
  --encrypt             Request SMB3 encryption
  --connection-timeout  TCP connection timeout in seconds (default: 60)
  -f, --foreground      Run in foreground (block until unmounted)
  --allow-other         Allow other users to access the mount
  --allow-root          Allow root to access the mount
  -v, --verbose         Enable debug logging

Python API

from smb_pyfuse import mount, unmount

# Mount (blocks in foreground mode)
mount(
    mountpoint="/mnt/smb",
    server="myserver.example.com",
    share="myshare",
    username="alice",
    password="s3cr3t",
    foreground=True,
)

# Unmount
unmount("/mnt/smb")

Or use the filesystem class directly:

from smb_pyfuse import SmbFuseFS

fs = SmbFuseFS(
    server="myserver.example.com",
    share="myshare",
    username="alice",
    password="s3cr3t",
)
fs.fuse_args.mountpoint = "/mnt/smb"
fs.fuse_args.add("allow_other")
fs.main()

License

MIT

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

smb_pyfuse-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

smb_pyfuse-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file smb_pyfuse-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for smb_pyfuse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d44c98b7e6dbe3440df8e9e12156314bde29e858e74d34ea8ec976d2ced8f16
MD5 2e2d374c45c2125f0b79ab2903a60a69
BLAKE2b-256 4c7d12ad58b10275db943b7baf27245aa5f49bdb322c7bbbf6a9d276e00b5897

See more details on using hashes here.

File details

Details for the file smb_pyfuse-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for smb_pyfuse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a0b8db8bdbb859e9e184f7f3d369f963a2ee31af9b02fa1887eacfbac25d5ee
MD5 087c34c045fe038b15fa2442b098ca22
BLAKE2b-256 c6effc2d897c5cf23a6ae088c6b111a44081a36833188d3015a6292016d5d9bb

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