sshfs-automount
v1.0.0
Published
Automated idempotent multi-server SSHFS mounting tool with legacy OpenSSH & modern Linux compatibility
Maintainers
Readme
🚀 Auto SSHFS Multi-Server
Automation script for mounting and unmounting remote directories across multiple servers (supporting both modern Linux distributions like Ubuntu 20.04/22.04/24.04 and legacy OS like CentOS 6.5) using SSHFS and SSHPASS or SSH Private Keys.
📋 Table of Contents
- Key Features
- System Requirements
- Directory Structure
- Configuration (
servers.conf) - Usage Guide
- Special Compatibility (CentOS 6.5 vs Modern Ubuntu)
- Troubleshooting
✨ Key Features
- 🔄 Idempotent Mounts: Automatically detects whether a directory is already mounted and skips it safely to avoid duplicate mounts or filesystem locks.
- 🔌 Broad SSH Compatibility: Out-of-the-box support for legacy OpenSSH (CentOS 6.5 / OpenSSH 5.3 with
diffie-hellman-group1-sha1/ssh-rsa) and modern OpenSSH without manual SSH config edits. - 🔑 Dual Authentication: Supports both password-based authentication (
sshpass) and SSH private key authentication. - ⚡ Auto-Reconnect & Keep-Alive: Configured with
ServerAliveIntervalandreconnectflags to prevent FUSE session drops across network fluctuations. - 🚀 Pre-flight Fast Reachability Check: Tests target host and port via sub-second native TCP probes before mounting to avoid long timeouts on unreachable hosts.
- 🧹 Graceful & Lazy Unmounting: Inspects
/procto report active locking processes and provides--lazydetachment. - 📊 Column-Aligned Status Dashboard: Clear, formatted table output for easy monitoring.
📦 System Requirements
Install the required packages on your local workstation:
# Ubuntu / Debian
sudo apt update && sudo apt install -y sshfs sshpass fuse3
# RHEL / CentOS / Rocky Linux
sudo yum install -y sshfs sshpass fuse
# or (CentOS 8+ / RHEL 8+)
sudo dnf install -y epel-release && sudo dnf install -y sshfs sshpass fuse3📂 Directory Structure
/mnt/automount/
├── mount.sh # Core execution script (mount/unmount/status)
├── servers.conf.example # Configuration template (safe for version control)
├── servers.conf # Active credentials (ignored by Git)
├── test_mount.sh # Module architecture self-test
├── CONTEXT.md # Domain glossary & ubiquitous language
├── README.md # English documentation
└── README.id.md # Indonesian documentation⚙️ Configuration (servers.conf)
Copy the example template to create your live configuration:
cp servers.conf.example servers.conf
chmod 600 servers.conf[!CAUTION] Security Notice: Never commit
servers.confto public Git repositories. It is included in.gitignoreby default. Always restrict permissions (chmod 600 servers.conf).
Line Format:
NAME|HOST|PORT|USER|PASSWORD|REMOTE_PATH|LOCAL_MOUNT_POINT|KEY_PATHField Definitions:
| Index | Field | Description | Default if omitted |
|---|---|---|---|
| 1 | NAME | Unique server identifier (no spaces) | (Required) |
| 2 | HOST | Target IP address or hostname | (Required) |
| 3 | PORT | Remote SSH port | 22 |
| 4 | USER | SSH username | root |
| 5 | PASSWORD | SSH password (or - if using SSH key) | (Required unless key specified) |
| 6 | REMOTE_PATH | Remote directory path to mount | / |
| 7 | LOCAL_MOUNT_POINT | Local destination mount path | /mnt/automount/<NAME> |
| 8 | KEY_PATH | Path to SSH private key (optional) | ~/.ssh/id_rsa (if password omitted) |
Configuration Examples:
# 1. Modern Ubuntu server with Password Auth
ubuntu-prod|192.168.1.50|22|ubuntu|PassUbuntu123|/var/www/html|/mnt/automount/ubuntu-prod|
# 2. Legacy CentOS 6.5 server with Password Auth
centos-legacy|192.168.1.60|22|root|PassCentos456|/home/data|/mnt/automount/centos-legacy|
# 3. Server using SSH Private Key Auth
prod-worker|10.10.1.20|22|deployer|-|/app|/mnt/automount/worker|~/.ssh/id_ed25519
# 4. Custom port with default local mount point
sftp-node|sftp.example.com|2222|sftpuser|SecretPass|/uploads||🖥️ Usage Guide
1. Mount Remote Shares
# Mount all servers listed in servers.conf
./mount.sh mount all
# or simply:
./mount.sh
# Mount a specific server by name
./mount.sh mount ubuntu-prod2. Check Mount Status
# Display dashboard for all servers
./mount.sh status
# Check status of a single server
./mount.sh status ubuntu-prod3. Safely Unmount
# Unmount all active servers
./mount.sh unmount all
# Unmount a single server
./mount.sh unmount ubuntu-prod
# Force unmount if directory is busy or held by active processes
./mount.sh unmount ubuntu-prod --lazy🛡️ Special Compatibility (CentOS 6.5 vs Modern Ubuntu)
Connecting between modern Linux clients (Ubuntu 22.04+) and legacy servers (CentOS 6.5 / OpenSSH 5.3) often fails due to deprecated crypto algorithms:
no matching key exchange method found(diffie-hellman-group1-sha1)no matching host key type found(ssh-rsa)no matching cipher found(aes128-cbc,3des-cbc)
mount.sh automatically includes backward-compatible algorithms in the SSH wrapper command:
-o HostKeyAlgorithms=+ssh-rsa \
-o PubkeyAcceptedKeyTypes=+ssh-rsa \
-o KexAlgorithms=+diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1 \
-o Ciphers=+aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc🔧 Troubleshooting
1. "fuse: device not found, try 'modprobe fuse'"
Run on host:
sudo modprobe fuse2. "Device or resource busy" during unmount
Another terminal or background process is inside the directory. Find locking processes or use --lazy:
./mount.sh unmount <server_name> --lazy3. Network unreachable timeout
mount.sh executes a 2-second fast reachability probe. If the remote port is blocked by firewall or down, it will immediately flag the server as unreachable without stalling other mount targets.
