Mount VPS Directory with SSHFS

Mount VPS Directory with SSHFS on Linux/Mac

June 2026 · 6 min read

SSHFS (SSH Filesystem) lets you mount a folder from your VPS onto your local machine like a network drive, with all traffic automatically encrypted through SSH. This is incredibly useful for several scenarios: edit VPS files directly with VS Code on your local machine, view images on the server in real-time, or drag-and-drop files between your server and local computer.

Installing SSHFS

# Ubuntu/Debian
sudo apt install sshfs -y

# macOS (requires macFUSE first)
brew install macfuse sshfs
# or download macFUSE from https://osxfuse.github.io

# Verify installation
sshfs --version

Mount VPS Folder with SSHFS

# Create mount point
mkdir -p ~/vps-files

# Mount using SSH key
sshfs ubuntu@VPS_IP:/var/www/html ~/vps-files \
  -o IdentityFile=~/.ssh/id_rsa \
  -o reconnect \
  -o ServerAliveInterval=15 \
  -o ServerAliveCountMax=3

# Mount using password (if not using key)
sshfs ubuntu@VPS_IP:/home/ubuntu ~/vps-files

# Verify mount was successful
df -h | grep vps-files
ls ~/vps-files

Unmount When Done

# Linux
fusermount -u ~/vps-files

# macOS
umount ~/vps-files
# or
diskutil unmount ~/vps-files

Automatic Mount with /etc/fstab (Linux)

sudo nano /etc/fstab

# Add this line:
ubuntu@VPS_IP:/var/www/html  /home/user/vps-files  fuse.sshfs  noauto,user,_netdev,reconnect,IdentityFile=/home/user/.ssh/id_rsa,allow_other  0  0
# Mount according to fstab
mount ~/vps-files

Using with VS Code Remote File

# After mounting, open VS Code
code ~/vps-files

# VS Code will see VPS files just like a local project
# Edit and save files and they will update on VPS instantly

# Or use Terminal in VS Code to work locally
# while files sync through SSHFS
Tip: Set -o cache=yes -o kernel_cache to enable local caching, which speeds up repeated file reads. However, if multiple people are editing files simultaneously, disable caching to always see the latest version.

Tuning Options for Stability and Speed

SSHFS with default settings often drops connections when the network stutters and can be slow with large file counts. Add these options when mounting to make it more resilient and responsive:

sshfs user@vps:/var/www ~/mnt/vps \
  -o reconnect \
  -o ServerAliveInterval=15 \
  -o ServerAliveCountMax=3 \
  -o cache=yes \
  -o kernel_cache \
  -o compression=yes \
  -o idmap=user
Tip: SSHFS works best for occasional file editing and configuration changes. It's not ideal for workloads with heavy random I/O (like databases or large builds) — for those, use rsync to sync files locally first, then work locally, which will be much faster.

Verify SSHFS is Working Correctly

# Check mount point
mount | grep sshfs
df -h | grep vps-files

# Test read/write
echo "test" > ~/vps-files/sshfs-test.txt
cat ~/vps-files/sshfs-test.txt

# Verify on VPS that the file exists
ssh ubuntu@VPS_IP "cat /var/www/html/sshfs-test.txt"
Tip: If SSHFS is slow, try -o Ciphers=aes128-ctr to use a lighter cipher, or -o compression=no if your network is already fast—compression overhead might not be worth it.

Common Issues & Troubleshooting

Error: "Transport endpoint is not connected"

The SSH connection dropped. You need to unmount and remount:

fusermount -uz ~/vps-files  # force unmount
sshfs ubuntu@VPS_IP:/path ~/vps-files -o reconnect

Permission denied when writing files

The user on the VPS doesn't have write permissions for that folder. Check ownership:

ssh ubuntu@VPS_IP "ls -la /var/www/html"
ssh ubuntu@VPS_IP "sudo chown ubuntu:ubuntu /var/www/html"

SSHFS very slow (high latency)

SSHFS is not suitable for VPS servers far away with high latency. Use rsync to sync files in batches instead, or choose a VPS closer to your location geographically to reduce latency.

macOS: "Permission denied" after macFUSE

You need to grant permission to macFUSE in System Preferences > Security & Privacy > General after first install:

sudo /Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse

Frequently Asked Questions

How are SSHFS and rsync different?

SSHFS mounts the filesystem in real-time—every operation is sent across the network immediately. rsync copies/syncs files in batches, transferring multiple files at once. SSHFS is better for interactive editing, while rsync is better for backups or deployments where efficiency is critical.

Can I use SSHFS on Windows?

Yes, through WinFSP + SSHFS-Win. Install both, then open \\sshfs\user@HOST\path\ in File Explorer. Alternatively, use WSL2 and run SSHFS in the Linux environment.

Is SSHFS secure compared to FTP?

Much more secure. SSHFS encrypts every byte with SSH, so your credentials and file contents never travel in plaintext. FTP sends username, password, and all file content as plaintext over the network.